Search code examples
eventspimcore

Pimcore Which event is fired when first time product save?


Pimcore How to get event for first time product save using backend.

I have to apply some logic for first time product creation in pimcore.

How to find event name.


Solution

  • The name of the event is 'object.preAdd'.

    If the Id of the saved object is 0, it's a newly created one

    \Pimcore::getEventManager()->attach("object.preAdd", function (\Zend_EventManager_Event $e) {
        // your code goes here
    });
    

    It would probably be best if you stick the code above into a custom made plugin to ensure it's executed on every call.

    See https://www.pimcore.org/docs/latest/Extending_Pimcore/Event_API_and_Event_Manager.html for more information