Phil Owen
Phil Owen

Reputation: 87

Magento Custom Order Export CSV Data

I'm trying to create a custom order export csv with lots of extra columns in my Magento install.

Here's an example CSV with the fields I need in the order export CSV: http://philowen.co/sample/SampleWebOrderLines.xlsx

Does anyone have any idea how I can do this or point me in the right direction?

Upvotes: 0

Views: 6201

Answers (5)

hamncheez
hamncheez

Reputation: 739

Its dated, but Inchoo has a good tutorial to get you started on Magento custom module development, and it luckily it walks you through the "export csv" functionality of the adminhtml:

http://inchoo.net/magento/tracing-magento-from-export-csv-to-save-file-ok-button/

Upvotes: 1

Priya Ponnusamy
Priya Ponnusamy

Reputation: 121

The easy way to do this is

Fall back the Grid.php file (app/core/Mage/Adminhtml/Block/Sales/Order/Grid.php)

then add your custom column like i did below:

//New columns added but hidded

$this->addColumn('custom_column', array(
   'header' => Mage::helper('sales')->__('Custom Column'),
   'index' => 'custom_column',
   'column_css_class'=>'no-display',
   'header_css_class'=>'no-display',
));

if you want to show this column in sales order grid just ignore these lines

   'column_css_class'=>'no-display',
   'header_css_class'=>'no-display',

also made change in

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->joinLeft('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('custom_column'));     
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

this means we have to add our custom column value to collection. For that we have to join our table with grid collection table.

Now go and check backend, export the orders. there will be our custom column added.

Upvotes: 1

Phil Owen
Phil Owen

Reputation: 87

thanks for the responses. Eventually, I installed the Xtento Order Export plugin and it's amazing.

I had to create a new XSL template from scratch but managed to get everything working, including Sales Tax and Delivery Charges on their own lines.

Upvotes: 0

Ankur Goyal
Ankur Goyal

Reputation: 110

You can try below extension.I hoe this should solve your purpose. http://ext4mage.com/export-orders-to-csv.html

This is a free extension

Upvotes: 0

Bob
Bob

Reputation: 8714

Maybe try using some of the modules that have that functionality

like this one http://www.magentocommerce.com/magento-connect/custom-export-orders-to-csv.html

Upvotes: 0

Related Questions