Registering Decorator to Manager

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
daan
Posts: 4
Joined: 03 Jun 2025, 20:27

Registering Decorator to Manager

Post by daan » 30 Jun 2025, 17:22

Hi Aimeos community,

I've been struggling for a few days with what feels like a basic task, and I'm hoping someone can point out what I'm missing.

My Environment:

Aimeos: 2025.04.1

TYPO3: 13.4.13

My Goal:
I need to execute some custom logic right after any Aimeos entity that affects a product's state is saved (e.g., an attribute, text, price, stock, etc.). The final goal is to update the product's mtime to reliably track all related changes for syncing with an external search index.

My Approach:
After inspecting the Aimeos core version I'm using, I've concluded that there is no central manager.item.saved signal fired from the MShop\Common\Manager\Base.php class. Therefore, the only clean, non-core-hacking way to achieve my goal is to use the Decorator pattern to intercept the save() method of the relevant managers.

The Problem:
I simply cannot get my decorator to trigger. I've created a minimal test case, but it's never instantiated.

Here is my setup, which I believe follows the official Aimeos Extension conventions:

1. Extension Structure:
My setup was generated by the Aimeos extension builder. It's a TYPO3 extension (meilisearch_aimeos_sync) that contains the Aimeos extension within its Resources/Private/Extensions/ directory. The PHP classes reside in the src/ folder of the Aimeos extension part.

2. manifest.php:
The manifest correctly includes the src and config directories.

PHP

<?php
return [
'name' => 'meilisearch_aimeos_sync',
'depends' => ['aimeos-core'],
'config' => ['config'],
'include' => ['src'],
];
3. Autoloader (composer.json of the TYPO3 extension):
I've configured the PSR-4 autoloader to point to the src directory, as required by my structure.

JSON

"autoload": {
"psr-4": {
"Aimeos\\": "src/"
}
},
4. The Decorator Class (src/MShop/Attribute/Manager/Decorator/LoggingDecorator.php):
I've created a minimal decorator, following the convention for a local attribute decorator.

PHP

<?php
namespace Aimeos\MShop\Attribute\Manager\Decorator;

use Aimeos\MShop\Common\Manager\Decorator\Base;
use Aimeos\MShop\Common\Manager\Iface;
use Aimeos\MShop\ContextIface;

class LoggingDecorator extends Base
{
public function __construct(Iface $manager, ContextIface $context)
{
// Using die() for absolute certainty during testing
die('!!! DECORATOR CONSTRUCTOR EXECUTED !!!');
parent::__construct($manager, $context);
}
}
5. The Aimeos Configuration (Resources/Private/Config/mshop.php):
I'm registering the decorator using its short name for the attribute manager, as required by the factory logic.

PHP

<?php
return [
'mshop' => [
'attribute' => [
'manager' => [
'decorators' => [
'local' => [
'LoggingDecorator'
]
]
]
]
]
];
What Happens:
Nothing. The die() statement is never executed when I save an attribute in the TYPO3 backend.

I have cleared all possible caches dozens of times (composer dump-autoload, TYPO3 C-level/all caches, Aimeos clearcaches job). I am certain this is not a cache issue.

I feel like I'm missing a totally banal, fundamental step related to how Aimeos extensions are bootstrapped within TYPO3.

My Question:
Based on the provided setup, what is the definitive, textbook way to make this decorator trigger work in this specific environment? Is there a different, undocumented convention or a required step for registering a manager decorator that I am missing?

Thanks in advance for any pointers. I'm completely stuck.

User avatar
aimeos
Administrator
Posts: 8620
Joined: 01 Jan 1970, 00:00

Re: Registering Decorator to Manager

Post by aimeos » 30 Jun 2025, 17:55

Your approach is correct but you are simply targeting the wrong manager. The attribute manager is only called when attributes are saved but they are only referenced by products so they are never changed. You have to wrap your decorator around the index manager class instead.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply