I am trying to hook catalog_product_save_after event. Here is config.xml
<events>
<catalog_product_save_after>
<observers>
<observer_name_here>
<class>My_Class_Model_Observer</class>
<method>methodToCall</method>
<type>singleton</type>
</observer_name_here>
</observers>
</catalog_product_save_after>
</events>
And below is the code that runs in methodToCall():
$product = Mage::getModel('catalog/product')->load(1);
$product->setName('TESTING 123');
$product->save();
Issue Is:
When the event catalog_product_save_after is fired. The code written in methodToCall() fire the catalog_product_save_after again. And according Magento EDA system methodToCall() called again which fires the catalog_product_save_after once again. So the system stuck in series of firing and listening the same event.
My Questions:
- How to avoid this situation ?
- Is there any way to disable to Magento event dispatch functionality for temporary purposes (without re-writing dispatchEvent method of Mage_Core_Model_App if possible).
- How to prevent infinite looping, if the observer fires the same event that instantiated the observer. Like in case above.