2013-04-10 36 views
1

如何創建一個observer客戶登錄在Magento創建一個觀察者爲客戶登錄magento

<events> 
     <customer_login> <!-- identifier of the event we want to catch --> 
      <observers> 
      <Vi_Cartproduct> <!-- identifier of the event handler --> 
       <type>singleton</type> <!-- class method call type; valid are model, object and singleton --> 
       <class>cartproduct/observer</class> <!-- observers class alias --> 
       <method>removeProduct</method> <!-- observer's method to be called --> 
       <args></args> <!-- additional arguments passed to observer --> 
      </Vi_Cartproduct> 
      </observers> 
     </customer_login> 
    </events> 

不工作

+0

你能解釋更多的細節您的要求,意味着你要自定義的頁面? – MagentoDiary 2013-04-10 10:25:18

+0

@Amit我更新了問題 – 2013-04-10 10:41:57

回答

1

如果你想定製只有主題,你有<customer_logged_in><customer_logged_out>手柄佈局,您可以添加或刪除任何塊以上的事件。

2

試試這個....

<events> 
    <customer_login> 
     <observers> 
      <vi_cartproduct_model_observer> 
       <type>singleton</type> 
       <class>Vi_Cartproduct_Model_Observer</class> 
       <method>removeProduct</method> 
      </vi_cartproduct_model_observer> 
     </observers> 
    </customer_login> 
</events> 
+0

事件不起作用 – 2013-04-10 11:30:18

+0

1.您是否激活了您的模塊? 2.向我展示你的觀察員班級代碼。 3.我再次修改上面的代碼檢查。讓我們知道發生了什麼? – MagentoDiary 2013-04-10 11:41:32

+0

<(爲getQuote() - > getItemsCollection()爲$項目PHP 類Vi_Cartempty_Model_Observer { 公共職能removeProduct($事件) { 的foreach法師:: getSingleton( '結帳/會話'))?> { 法師:: getSingleton('checkout/cart') - > removeItem($ item-> getId()) - > save(); } } } – 2013-04-10 11:52:23