Observer for Magent product after save

2019-08-03 22:42发布

问题:

I am trying to add Observer to the Product status update event on backend. But it does not triggering the event.

<?xml version="1.0"?>      
<config>     
    <modules>      
        <Mage4u_Customredirect>     
            <version>0.1.0</version>      
        </Mage4u_Customredirect>      
    </modules>     
    <global>        
        <events>     
            <catalog_product_status_update>      
                <observers>     
                    <Mage4u_Customredirect_Catalog_product>     
                        <type>singleton</type>  
                    <class>mage4u_customredirect/observer</class>   <method>on_catalog_product_status_update</method>  </Mage4u_Customredirect_Catalog_product>              

                </observers>  
            </catalog_product_status_update> 
        </events>  
    </global>    
</config> 

And the observer function is to receive the status of the product that was updated and based on that i need to update it in another server.

<?php


class Mage4u_Customredirect_Model_Observer
{


    public function on_catalog_product_status_update(Varien_Event_Observer $observer)
    {  
        Mage::log("test " ,null,"test");

        var_dump($observer);die();  

        }


}


?>

But it does not triggering this event. Please can someone tel me why its not working.

回答1:

You should use the same notation here for class name as you use in Mage::getModel() factory method, e.g.: <class>mage4u_customredirect/observer</class>. Do not forget delete cache after this change to make it work.



标签: magento