2016-02-26 14 views
0

我希望觀察者能夠像刪除產品,更新以及從前端和後端添加產品一樣跟蹤引用中的更改。這個觀察者應該在magento本地代碼之後運行。跟蹤magento中引用更改的事件

有喜歡低於報價的過程中執行的許多事件,但我不知道它的觀察者將是適合我requirement--

sales_quote_remove_item

sales_quote_add_item

sales_quote_product_add_after

sales_quote_item_collection_products_after_load

checkout_cart_add_product_complete

checkout_cart_save_before

checkout_cart_save_after 等等

回答

0

您可能無法通過使用一個單一的事件來實現這一目標,而是你可以寫一個觀察者a第二把這個觀察員多個事件..

 <sales_quote_product_add_after> 
     <observers> 
      <sales_quote_product_add> 
      <type>singleton</type> 
      <class>my_module/observer</class> 
      <method>myfunction</method> 
      </sales_quote_product_add> 
     </observers> 
     </sales_quote_product_add_after>   


     <checkout_cart_add_product_complete> 
     <observers> 
      <checkout_cart_add_product> 
      <type>singleton</type> 
      <class>my_module/observer</class> 
      <method>myfunction</method> 
      </checkout_cart_add_product> 
     </observers> 
     </checkout_cart_add_product_complete>   

活動,你可以看到 sales_quote_remove_item sales_quote_item_qty_set_after sales_quote_product_add_after

https://www.nicksays.co.uk/magento-events-cheat-sheet-1-9/

您可以在應用放在自己的 修改Mage.php事件文件夾

public static function dispatchEvent($name, array $data = array()) 
{ 
Varien_Profiler::start('DISPATCH EVENT:'.$name); 
$result = self::app()->dispatchEvent($name, $data); 
Varien_Profiler::stop('DISPATCH EVENT:'.$name); 

//log your event 
Mage::log("Event name is $name",null,'event.log'); 

return $result; 
} 

做你的動作,像添加到購物車,刪除/更新數量,然後檢查var/log中的event.log