以下是我如何描述sales_order_place_after事件
<models>
<chatattributes>
<class>Rockstar_Chatattributes_Model</class>
</chatattributes>
<chatattributes>
<class>Rockstar_Chatattributes_Model</class>
<resourceModel>chatattributes_resource</resourceModel>
</chatattributes>
<chatattributes_resource>
<class>Rockstar_Chatattributes_Model_Resource</class>
</chatattributes_resource>
</models>
</global>
<frontend>
<events>
<sales_order_place_after>
<observers>
<place_order>
<type>singleton</type>
<class>chatattributes/observer</class>
<method>placeOrder</method>
</place_order>
</observers>
</sales_order_place_after>
<sales_quote_item_set_product>
<observers>
<quote_item>
<type>singleton</type>
<class>chatattributes/observer</class>
<method>setQuoteItem</method>
</quote_item>
</observers>
</sales_quote_item_set_product>
<add_to_cart_before>
<observers>
<add_to_cart>
<type>singleton</type>
<class>chatattributes/observer</class>
<method>addToCart</method>
</add_to_cart>
</observers>
</add_to_cart_before>
</events>
</frontend>
这是我的Observer.php(Rockstar / Chatattributes / Model / Observer.php)
<?php
class Rockstar_Chatattributes_Model_Observer
{
public function placeOrder($observer) {
var_dump('Never Ever change Magento Core code'); die;
}
public function setQuoteItem($observer) {
var_dump('quote item'); die;
}
public function addToCart($observer) {
var_dump('added to cart'); die;
}
}
所以,当我下订单时,我想在我的观察者中调用方法'placeOrder'...但我不能.....我已经删除VAR文件夹并以777权限再次创建它。
答案 0 :(得分:1)
//置于全球标签&amp;不在前端标签下
<global>
<events>
<sales_order_place_after>
<observers>
<place_order>
<type>singleton</type>
<class>chatattributes/observer</class>
<method>placeOrder</method>
</place_order>
</observers>
</sales_order_place_after>
</events>
</global>
答案 1 :(得分:0)
在您的XML中,您正在寻找带有&#39; chatattributes&#39;的Observer类。模型。 需要定义模型的简写并将其与XML中的模型类相关联。 对于您提供的模型,XML模型定义如下所示:
<global>
<models>
<chatattributes>
<class>CompanyName_ExtensionName_Model</class>
</chatattributes>
</models>
</global>