0

Testing out observers and following tutos , i have created an observer for 'catalog_product_save_after' that worked. But searching through the files i cannot find the Mage::dispatchEvent('catalog_product_save_after');

How is this possible?

This question is interesting for me because at first the observer i have setted was not working and i thought it was because the event were simply not existing.

  • 2
    It has to be somewhere, but the declaration doesn't always go the way you pointed out, it's sometimes like $this->_eventPrefix.'_save_after' you see? – Julien Lachal May 13 '14 at 15:10
  • not easy to verify if an event is indeed existing in our version – Matoeil May 13 '14 at 15:21
  • Indeed. But are you sure that it wasn't fired because of Magento? or is it because your product didn't meet the requirements for it to be fired? – Julien Lachal May 13 '14 at 15:36
  • it was initially not fired because of errors in my config.xml – Matoeil May 13 '14 at 15:55
  • I see, is it ok now? – Julien Lachal May 13 '14 at 16:02
3

i strongly recommend to set this observer as a tool to trace possible hooks when working in creating new observer for any specific event

How to Know The Magento Event that We Want to Hook

thus i have created in the module Logevent the config.xml

     <?xml version="1.0" encoding="UTF-8"?>

<modules>
    <Maticode_Logevent>
        <version>0.1</version>
    </Maticode_Logevent>
</modules>


<global>
    <models>
        <Logevent>
            <class>Maticode_Logevent_Model</class>
        </Logevent>
    </models>

    <events>


        <controller_action_predispatch>
            <observers>
                <Logevent>
                    <type>singleton</type>
                    <class>Logevent/observer</class>
                    <method>controller_action_predispatch</method>
                </Logevent>
            </observers>
        </controller_action_predispatch>

    </events>
</global>

and the Model/observer.php

            <?php

 class Maticode_Logevent_Model_Observer {
public function controller_action_predispatch($observer) {
    Mage::log ( $observer->getEvent ()->getControllerAction ()->getFullActionName (),null, 'eventlog.log' );
}
  }

This way , in the

        var/log/eventlog.log file  

i can visualize a possible hook on any tested actions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.