我希望观察者跟踪Quote中的更改,例如在删除产品,更新,从前端和后端添加产品时。该观察者应该在magento本机代码之后运行。
下面有许多事件在报价期间执行,但我不确定哪个观察员符合我的要求 -
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 :(得分:0)
您可能无法通过使用单个事件来实现此目的,但您可以编写单个观察者并为多个事件调用此观察者。
<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