我正在尝试建立一个观察者,该观察者将在订单完成时触发命令。我尝试将几个订单标记为完整,但不会触发观察者。
.xml在etc / modules中
<?xml version="1.0"?>
<config>
<modules>
<Test_ReviewRequestTrigger>
<version>1.0</version>
</Test_ReviewRequestTrigger>
</modules>
<global>
<models>
<review_request_trigger>
<class>Test_ReviewRequestTrigger_Model</class>
</review_request_trigger>
</models>
<events>
<sales_order_save_after>
<observers>
<review_request_trigger>
<type>singleton</type>
<class>Test_ReviewRequestTrigger_Model_Observer</class>
<method>implementOrderStatus</method>
</review_request_trigger>
</observers>
</sales_order_save_after>
</events>
</global>
</config>
在应用程序/代码/.../ReviewRequestTrigger/etc/config.xml中的config.xml
<?xml version="1.0"?>
<config>
<modules>
<Test_ReviewRequestTrigger>
<active>true</active>
<codePool>local</codePool>
</Test_ReviewRequestTrigger>
</modules>
</config>
app/code/.../ReviewRequestTrigger/Model/Observer.php
中的Observer.php
class Test_ReviewRequestTrigger_Model_Observer
{
public function implementOrderStatus($event)
{
Mage::log("hello", null, 'test_ReviewRequestTrigger.log');
$order = $event->getOrder();
$stateProcessing = $order::STATE_COMPLETE;
// Only trigger when an order enters processing state.
if ($order->getState() == $stateProcessing && $order->getOrigData('state') != $stateProcessing) {
}
}
}
答案 0 :(得分:-1)
您的config.xml
文件中有几个错误可能是罪魁祸首。以下是有关how to set up an observer的更多信息的链接,但以下是适用于您的问题的相关代码:
<events>
<sales_order_save_after>
<observers>
<ReviewRequestTrigger>
<type>singleton</type>
<class>ReviewRequestTrigger/observer</class>
<method>implementOrderStatus</method>
</ReviewRequestTrigger>
</observers>
</sales_order_save_after>
</events>
请注意<ReviewRequestTrigger>
包装器和其中的<class>
标签的更改。