我想在我的模塊(app/code/community/Test/Shipping)中實現觀察者。Magento 1.6.2事件觀察者不工作
我的文件有:應用程序/代碼/社區/測試/運輸/等/ config.xml中全球部分僅
<global>
<models>
<test_shipping>
<class>Test_Shipping_Model</class>
</test_shipping>
</models>
<events>
<checkout_type_onepage_save_order_after>
<observers>
<Test_Shipping_Observer>
<type>singleton</type>
<class>test_shipping/observer</class>
<method>checkout_type_onepage_save_order_after</method>
</Test_Shipping_Observer>
</observers>
</checkout_type_onepage_save_order_after>
</events>
</global>
應用程序/代碼/社區/測試/運輸/ Model/Observer.php我用curl替換了一些值,但它的測試結果和正確的值一起工作。
<?php
類Test_Shipping_Model_Observer {
public function checkout_type_onepage_save_order_after(Varien_Event_Observer $observer) {
$requests = array(
"username" => "test",
"password" => "test",
"environment" => "development",
"action" => "ship",
"service_id" => "1"
);
$url = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requests));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
}
}
應用程序的/ etc /模塊/ Test_Shipping.xml與起始和結束的配置標籤,不可能讓他們在我的代碼示例。
<modules>
<Test_Shipping>
<active>true</active>
<codePool>community</codePool>
</Test_Shipping>
</modules>
但觀察員沒有工作,任何人都可以幫助我嗎?有沒有辦法來檢查方法是否被調用,所以我會知道觀察者的作品,但我的捲曲doesnt。
法師::日誌( '只是分派的事件');在日誌中,但法師::日誌('甚至應該在這裏捕捉');沒有,所以這意味着我的觀察員不工作 – user1773888
是的。嘗試在中重命名,並按照我的建議重命名觀察者函數。 –