我創建一個Magento模塊,我希望觀察者觸發時,我的自定義orderstatus被選中。Magento觸發觀察者與自定義orderstatus
實際情況: 人們選擇:'Payment Received'在觀察者中//DO STUFF
被觸發。
這不起作用,所以這裏有什麼問題? (狀態正確顯示了雖然):-(
config.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MOD_PaidStatus>
<version>1.0.0</version>
</MOD_PaidStatus>
</modules>
<global>
<sales>
<order>
<statuses>
<payment_received translate="label"><label>Payment Received</label></payment_received>
</statuses>
<states>
<processing translate="label">
<label>Processing</label>
<statuses>
<processing default="1"/>
<payment_received default="2" />
</statuses>
<visible_on_front/>
</processing>
<pending translate="label">
<label>Pending</label>
<statuses>
<pending default="1"/>
<payment_received default="2" />
</statuses>
<visible_on_front/>
</pending>
</states>
</order>
</sales>
<events>
<sales_order_resource_save_attribute_after>
<observers>
<PaidStatus>
<class>MOD_PaidStatus/observer</class>
<method>observeAttributeChange</method>
<type>singleton</type>
</PaidStatus>
</observers>
</sales_order_resource_save_attribute_after>
</events>
</global>
</config>
而且我Observer.php樣子:
class MOD_PaidStatus_Model_Observer {
public function observeAttributeChange($observer){
$attribute = $observer->getEvent()->getAttribute();
if ($attribute->getAttributeCode() == 'status') {
mail('[email protected]', 'testcase', 'foo bar?');
}
}
}
謝謝,我已經更新了問題中的代碼,但我不確定我是否理解。我仍然沒有收到電子郵件:[email protected] –
你可以檢查是否調用了「observeAttributeChange($ observer)」函數嗎? (使用調試器或插入日誌調用)。如果是,attributeCode是否等於'狀態'? –