Magento: Obtain Id for order, listening to the event checkout_onepage_controller_success_action

后端 未结 4 1918
野的像风
野的像风 2021-01-15 16:24

When I look at the event checkout_onepage_controller_success_action and works, but I can not get the Id of the newly created order.

Anyone have any idea

4条回答
  •  萌比男神i
    2021-01-15 16:38

    That event probably gets called before the action itself executes. Can you use sales_order_save_after instead?


    EDIT: Here's your ID code. In your observer:

    public function setLinkStatus($observer) {
        $order = $observer->getEvent()->getOrder(); 
        $id = $order->getId();
    
        // do something useful
    }
    

提交回复
热议问题