cancel
Showing results for 
Search instead for 
Did you mean: 

event after both order and order_item saved in table.

SOLVED

event after both order and order_item saved in table.

I need the item_id while order is placed . i get all the information except item_id , while using event "sales_order_save_after" . while search in net i found event "checkout_onepage_controller_success_action" but some say this event call only for front end orders and it may not call if payment gateway redirects back to the merchant website. I need event call after both  order and order_item saved in table.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: event after both order and order_item saved in table.

You can get a list of events from below blogs,

Magento 2 All Events

 

You can use sales_order_payment_save_after event for your case.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

View solution in original post

5 REPLIES 5

Re: event after both order and order_item saved in table.

You can get a list of events from below blogs,

Magento 2 All Events

 

You can use sales_order_payment_save_after event for your case.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: event after both order and order_item saved in table.

Hi Sundar,

The  sales_order_place_after event will help you to get both the order and item information. Please try this event.

 

Hope it helps!

Re: event after both order and order_item saved in table.

Did you provide some example code . 

i use following code to get order id

 

$order = $observer->getEvent()->getOrder();
$order_id = $order->getId();

 

but not working for sales_order_payment_save_after event

Re: event after both order and order_item saved in table.

Try with below solutions,

$payment = $observer->getDataByKey('payment');
$order = $payment->getOrder();
$order->getId()
$order->getIncrementId();
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: event after both order and order_item saved in table.

Hi,

Did you tried this event "sales_order_place_after".

$order = $observer->getEvent()->getOrder();