---
title: "How to Export Specific Custom Orders Data Field in CSV from Magento"
url: "https://magecomp.com/blog/export-specific-custom-orders-data-field-csv-magento/"
date: "2019-08-09T17:23:00+00:00"
modified: "2019-08-09T17:23:00+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "General"
word_count: 407
reading_time: "3 min read"
summary: "Having thousands of orders inside your Magento Store makes difficult to look for a specific order data even if you use a backend filter system. And, manually going through all order details is not ..."
description: "Having thousands of orders inside your Magento Store makes difficult to look for a specific order data even&hellip;"
keywords: "General"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Unlocking the Future of Search with Generative AI: Google&#8217;s Search Generative Experience (SGE)"
    url: "https://magecomp.com/blog/googles-search-generative-experience/"
  - title: "How to Disable The Cache for Block in Magento 2"
    url: "https://magecomp.com/blog/disable-cache-block-magento-2/"
  - title: "Codelobster IDE &#8211; The Powerful Multi-Platform Magento IDE"
    url: "https://magecomp.com/blog/codelobster-ide-powerful-multi-platform-magento-ide/"
---

# How to Export Specific Custom Orders Data Field in CSV from Magento

_Published: August 9, 2019_  
_Author: Dhiren Vasoya_  

![How to Export Custom Orders CSV using given orders id in Magento 2](https://magecomp.com/blog/wp-content/uploads/2019/08/How-to-Export-Custom-Orders-CSV-using-given-orders-id-in-Magento-2-1024x332.webp)

Having thousands of orders inside your Magento Store makes difficult to look for a specific order data even if you use a backend filter system. And, manually going through all order details is not so easy because there is also so many unnecessary other order related information along with data for which you are actually looking for. Many times it happens that as a store owner, you need very specific data that you have to share with your shipping provider or external services that you are using for your customer. Magento backend doesn’t allow you to export such data from the backend.
At that time getting help from Magento Expert Developer will help you to quickly export such data using some sort of scripts or code. We have come across so many requirements to export some specific order data from Magento. That’s why we are back with another blog series that will help you to quickly export last any number of data with only required fields.
To do the same first we need to create a “**orderexport.php**” php script using below code.

```

ini_set('display_errors', 1);
require_once('app/Mage.php');
Mage::app();

try {
    $orders = Mage::getModel('sales/order')->getCollection()
        ->setOrder('created_at', 'desc')
        ->setPageSize(10); //export data from last give orders id  to 10 ex.
    $fp = f0pen(Mage::getBaseDir() . "/orderexport.csv", "w+");
    $csvHeader = array('Order ID', 'Customer Email', 'Customer First Name', 'Customer Last Name'); //CSV Header title
    fputcsv($fp, $csvHeader, ","); //save sequence as give csv header title add more to add both side.
    foreach ($orders as $order) {
        fputcsv($fp, array(
            //save sequence as give csv header title add more to add both side.
            $order->getIncrementId(),
            $order->getCustomerEmail(),
            $order->getCustomerFirstname(),
            $order->getCustomerLirstname()
        ));
    }
    fclose($fp);
    echo 'orderexport.csv Successfully created.';

}catch (Exception $e){
    echo $e->getMessage();
}
?>
```

Place this script file in the root server of your Magento and run it by hitting file URL.
I.e. **yourstoreurl.com/orderexport.php**
That’s it, once a successful script runs it will export order data in CSV file with specified field data. You can find that “**orderexport.csv**” in the root folder of your hosting. You are free to add or remove order fields that you want to export from your Magento.
Lastly, if you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends and Let us know if you are facing any issue while implementing this code.
Happy Coding!


---

_View the original post at: [https://magecomp.com/blog/export-specific-custom-orders-data-field-csv-magento/](https://magecomp.com/blog/export-specific-custom-orders-data-field-csv-magento/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-22 05:35:59 UTC_  
