How to get entity_id after order is placed.

How can i get order details with entity id in Magento2 rest api ?

  • you wany customer entity id from order? – Amit Bera Sep 17 '18 at 6:17
  • yes, by using entity id can we get order details ? – Pratap varma Penmetsa Sep 17 '18 at 6:33
  • mean entity id means Customer Id? or order id? – Amit Bera Sep 17 '18 at 6:36
  • order id and how can i get order details of specific user. – Pratap varma Penmetsa Sep 17 '18 at 6:37

You can hook to sales_model_service_quote_submit_success event, It is execute after order is placed.

Add event to your_module/etc/frontend/events.xml

<event name="sales_model_service_quote_submit_success">
        <observer name="your_module_sales_model_service_quote_submit_success" instance="Your_Vendor\Your_Module\Observer\SalesModelServiceQuoteSubmitSuccessObserver"/>

Create observer

namespace Your_Vendor\Your_Module\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class SalesModelServiceQuoteSubmitSuccessObserver implements ObserverInterface

     * Fires when sales_order_place_after is dispatched
     * @param Observer $observer
    public function execute(Observer $observer)
        //Order information
        $order = $observer->getEvent()->getOrder();
        //Quote information
        $quote = $observer->getEvent()->getQuote();

        //Get customer_id from order
        $customerId = $order->getCustomerId();

        //Or Get customer_id from quote
        $customerId = $quote->getCustomerId();

Header:Authorization Bearer Key

use admin token



  • how can i get order_id or entity_id after placing order – Pratap varma Penmetsa Sep 17 '18 at 9:53
  • Use sales_order_place_after event where you can get all order details – Sairam Sigirisetty Sep 17 '18 at 10:14
  • i am using rest api so how can i get it – Pratap varma Penmetsa Sep 17 '18 at 10:21
  • 1
    You are using rest API to place order ? If yes it will return order id – Sairam Sigirisetty Sep 17 '18 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.