How to get entity_id
after order is placed.
How can i get order details with entity id in Magento2 rest api ?
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"/>
</event>
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
baseurl/rest/all/V1/orders/orderid
baseurl/rest/all/V1/orderlist?searchCriteria[filter_groups][0][filters][0][field]=customer_id&searchCriteria[filter_groups][0][filters][0][value]=15
Customer Id
? or order id?