🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Get Order Data From Magento 2 “sales_order_place_after” Event?

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Admin would want to use order data after an order is placed for many purposes. Admin may want the order data to send to shipping carriers for order delivery or send an SMS to the customer for acknowledging their order or calculate taxes based on product, location, and other such factors. To retrieve the order data, one needs to use Events and Observers in Magento 2.

Events in Magento 2 are dispatched based on an action performed and it passes data to the observer. Observers are Magento classes that are executed when an event is dispatched. Here, we will make use of this concept to get order data from Magento 2 “sales_order_place_after” event.

Method to Get Order Data FromMagento“sales_order_place_after” Event

Create events.xml file at app/code/Vendor/Extension/etc/

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_place_after">
        <observer name="place_order_after" instance="Vendor\Extension\Observer\Orderplaceafter"/>
    </event>
</config>

Create Orderplaceafter.php at app/code/Vendor/Extension/Observer/

<?php
 
namespace Vendor\Extension\Observer;
 
use Magento\Framework\Event\ObserverInterface;
use Psr\Log\LoggerInterface;
 
class Orderplaceafter implements ObserverInterface
{
    protected $logger;
 
    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }
 
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $order = $observer->getEvent()->getOrder();
        } catch (\Exception $e) {
            $this->logger->info($e->getMessage());
        }
    }
}

Follow these steps and get order data from Magento 2 “sales_order_place_after” event to use it either for better administration or to enhance the customer experience!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.