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.

7
  • 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? May 13, 2014 at 15:10
  • not easy to verify if an event is indeed existing in our version
    – Matoeil
    May 13, 2014 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? May 13, 2014 at 15:36
  • it was initially not fired because of errors in my config.xml
    – Matoeil
    May 13, 2014 at 15:55
  • I see, is it ok now? May 13, 2014 at 16:02

1 Answer 1

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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