내 모듈 (app/code/community/Test/Shipping)에 observer를 구현하려고합니다.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 컬링의 일부 값을 바꿔서 테스트했지만 올바른 값으로 작동합니다.
<?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, 내 코드 예제에서 그들을 얻을 couldnt한다.
<modules>
<Test_Shipping>
<active>true</active>
<codePool>community</codePool>
</Test_Shipping>
</modules>
하지만 관찰자는 작동하지 않습니다. 아무도 도와 줄 수 없나요? 메서드가 호출되었는지 확인할 수있는 방법이있어 관찰자가 작동하지만 컬이 왜곡되는 것을 알 수 있습니다.
마법사 : 로그 ('바로 발송 이벤트'); 로그에 있었지만 Mage :: log ('여기에 캡처해야합니다'); didnt한다. 그래서 그것은 나의 관찰자 doesnt가 일하는 것을 의미한다 – user1773888
그래.에서 의 이름을 바꾸고 내가 제안한대로 관찰자 함수의 이름을 변경하십시오. –