Magento Tutorials

How to Export Orders to CSV in Magento 2

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

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

magento 2 orders export

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>

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="" 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" />


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

Hope this helped!

See also:
How to Export Products to CSV in Magento 2
How to Refund an Order in Magento 1 & 2

Is it helpful?


A knowledge craver who always strive to be wiser everyday.

Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
1 month ago

Thanks for the info! What do you think would be the best solution for this scenario? Daily order export to csv of customer details/shipment info/item specifcs, then able to import a csv which has tracking nmbers?