Magento – How to Trace Events and Alternatives to Mage::dispatchEvent

event-observer

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.

Best Answer

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

Related Topic