大家好我在magento 1.14企业工作。我正试图获得订单ID后,我在使用此事件进行多次结账结账
sales_order_place_after
我也试过这个
checkout_submit_all_after
但是我在这个事件中什么也没得到,我想获得订单ID
这是我的配置代码
has_attached_file :attachment, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :attachment, :content_type => ["application/pdf", "application/zip", "application/x-zip", "application/x-zip-compressed","application/octet-stream","image/jpg", "image/png", "image/jpeg", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]
这个函数的代码
<sales_order_place_after>
<observers>
<Webkul_Marketplace_Model_Observer>
<type>singleton</type>
<class>Webkul_Marketplace_Model_Observer</class>
<method>afterPlaceOrder</method>
</Webkul_Marketplace_Model_Observer>
</observers>
</sales_order_place_after>
它在这一行给我错误调用成员函数getId()为null 任何人都可以告诉我我错过了为什么我的观察者没有给我什么我已经检查了同样的情况一页及其工作正常。
谢谢..
答案 0 :(得分:0)
请尝试通过以下方式获取订单:
$order = $observer->getEvent()->getOrder();
所以结果:
public function afterPlaceOrder($_observer) {
$helper = Mage::helper('marketplace');
$_event = $_observer->getEvent();
$_order = $_event->getOrder();
if (!$_order) {
return $this;
}
$_lastOrderId = $_order->getId();
}