How to Get Order Data From Magento “sales_order_place_after” Event
Earlier, I had given the solution to get order data from Magento 2 “sales_order_place_after” event.
A client with a similar requirement for Magento 1 wanted to use the solution to retrieve the order data and send a payment confirmation SMS to store customers.
With a view to sharing the solution with my readers, here’s the stepwise method to get order data from Magento “sales_order_place_after” event
Method to Get Order Data From Magento “sales_order_place_after” Event:
- Place the below event code in your config.php file
123456789101112131415<global>.....<events><sales_order_place_after><observers><order_place_after><type>model</type><class>extension/observer</class><method>orderAfterObserver</method></order_place_after></observers></sales_order_place_after></events>.......</global> - Create Observer.php file at app/code/local/Vendor/Extension/Model/ folder
12345678910<?phpclass Vendor_Extension_Model_Observer{public function orderAfterObserver(Varien_Event_Observer $observer){$order = $observer->getEvent()->getOrder();$orderId = $order->getIncrementId();//Write Your code here.}}
Follow these steps and easily get order data from Magento “sales_order_place_after” event to implement features useful to improve customer experience or administration tasks!
Do let me know if the solution was helpful to you and how you used it in your Magento store. Also, feel free to discuss any doubts regarding the method in the Comments section below 🙂
Thanks.
Sanjay 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.
Prev
How to Remove Index.php from URL in Magento
How to Add Magento 2 Sort by Price for Low to High & High to Low Options
Next