I've added the a few columns to the sales_flat_order_grid
table.
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).
<add_order_grid_column_handle>
<reference name="sales_order.grid">
<action method="addColumnAfter">
<columnId>product_names</columnId>
<arguments>
<header>Product(s) Name(s)</header>
<index>product_names</index>
<type>text</type>
</arguments>
<after>created_at</after>
</action>
[...]
</reference>
</add_order_grid_column_handle>
<adminhtml_sales_order_grid>
<update handle="add_order_grid_column_handle" />
</adminhtml_sales_order_grid>
<adminhtml_sales_order_index>
<update handle="add_order_grid_column_handle" />
</adminhtml_sales_order_index>
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:
$this->getLayout()->createBlock('adminhtml/sales_order_grid');
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?