There are a couple of questions relating to adding a custom email field to the order grid. For example, this and this.
However, both these create a problem when you try and filter. What happens is that whilst you can search the new email field, if you search via order ID, store, or Purchased On - then you are taken to the Dashboard, and when you return to the Order grid, you get an error.
For the sake of example, I am using the following code to make the join in _prepareCollection
$collection->getSelect()->joinLeft(
array('myorder'=>'sales_flat_order'),
'myorder.entity_id = main_table.entity_id',
array('myorder.customer_email')
);
and the following to call it in _prepareColumns:
$this->addColumn('customer_email', array(
'header' => $this->helper('sales')->__('Customer Email'),
'index' => 'customer_email',
'filter_index' => 'myorder.customer_email',
));
Anyone any ideas what is wrong with this code?