Table of contents
This guide is gonna walk you through how to export orders in Magento into CSV file, starting from the easiest way by using Magento backend, to a more advanced way of using script. Either way, you will end up with a CSV file containing all the data from your Orders grid.
Export orders from Magento backend
In your Magento backend, go to Sales > Orders
In the Orders panel that follows, you should have the following columns by default:
- ID
- Purchase Point
- Purchase Date
- Bill-to Name
- Ship-to Name
- Grand Total (Base)
- Grand Total (Purchased)
- Status
- Action
- Allocated sources
- Braintree Transaction Source
Here you can Export your Orders data by clicking on the Export drop down and tick CSV
Click Export and the generated CSV will contain the data in this Default view
Export orders programmatically with custom data
Alternatively, you can also programmatically add new columns in your Orders grid and run Observer to export Orders CSV.
Create new column in vendor/magento/module-sales/view/adminhtml/ui_component/sales_order_grid.xml
<column name="custom_product_name" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> <item name="label" xsi:type="string" translate="true">Custom Product Name</item> </item> </argument> </column>
Make changes to the sales_order_grid
table by running the following upgrade schema:
ALTER TABLE `sales_order_grid` ADD `custom_product_name` VARCHAR( 255 ) NOT NULL ;
Run Observer when an order is submitted successfully
For example, in events.xml
:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="checkout_submit_all_after"> <observer name="yourcompany_yourmodule_checkout_submit_all_after" instance="YourCompany\YourModule\Observer\ProcessOrder" /> </event> </config>
And in the observer:
public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getOrder(); $quote = $observer->getQuote(); // Do whatever you want here return $this; }
Click Export.
Export orders using an extension
As the default orders export option in Magento is still pretty limited, the better way to do this would be to use an extension to have the job done for you. Fortunately, there’s no shortage of export order extensions available on the market for you to choose from.
Below is a list of current best extensions for exporting orders in Magento 2
- Magento 2 Import Export Order by BSS Commerce ($129)
- Order Export by Mageplaza ($129)
- Export Orders by Amasty ($199)
- Order Export by Xtento ($199)
- Order Import/Export by MageModule ($149.99)
- Orders Export and Import by Aitoc ($169)
- Magento 2 Order Export by FMEExtension ($129)
Hope this helped!
See also:
How to Export Products to CSV in Magento 2
How to Refund an Order in Magento 1 & 2