I've added the a few columns to the sales_flat_order_gridtable. The values are obtained in these two events sales_order_resource_init_virtual_grid_columns (using addVirtualGridColumn() ) and sales_order_resource_update_grid_records (updating the table values for some more complex joins).

    <reference name="sales_order.grid">
        <action method="addColumnAfter">
                <header>Product(s) Name(s)</header>

    <update handle="add_order_grid_column_handle" />
    <update handle="add_order_grid_column_handle" />

However, when exporting a csv of the grid, it doesn't include the custom columns.

I found that the file is loaded using the grid block like this:


But that, for some reason, is not loading the layout update I have written above, so the new columns are not used...

Is there any settings, or layout handle to add to this columns, so they are also used in the exported csv?

  • Is it your error solved?
    – Gem
    Commented Apr 27, 2017 at 6:41

1 Answer 1


The grid export is a different controller action, so the layout handle would be different, something like adminhtml_sales_order_exportCsv (didn't check if this is the exact handle). However, exportCsvAction doesn't seem to call loadLayout so probably using layout updates here wouldn't work.

From what I could tell by briefly looking at the code, there are three options, none of them extremely clean:

  1. Create a custom grid extending Mage_Adminhtml_Block_Sales_Order_Grid and add your logic to the _prepareColumns and _prepareCollection methods, then replace the core grid with the custom one
  2. Overwrite the Mage_Adminhtml_Block_Sales_Order_Grid block and add your logic in _prepareColumns and _prepareCollection.
  3. Overwrite the Mage_Adminhtml_Sales_OrderController controller, exportCsvAction and call addColumn on the $grid block object to add your columns
  • Thanks. I went with option 3. Calling the same methods as in the layout, but in plain old php. Like so: $grid->addColumnAfter( 'product_names', array( 'header' => "Product(s) Name(s)", 'index' => "product_names", 'type' => 'text', ), 'created_at' ); Commented Sep 18, 2015 at 21:12
  • @ Adi : I am using this method magento.stackexchange.com/a/171754/51361 for adding custom field on sales order grid. but when i export, the custom added column values not exported, how can i solve this error.
    – user51361
    Commented Apr 27, 2017 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.