问题
I have found several ways online but none seem to work. Does anyone know how to add the customer email to the grid for orders in Magento 1.4
回答1:
copy
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
to
app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
then under the following line
$collection = Mage::getResourceModel($this->_getCollectionClass());
add
$collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email'));
then in the _prepareColumns() method add
$this->addColumn('customer_email', array(
'header' => Mage::helper('sales')->__('Customer Email'),
'index' => 'customer_email',
'filter_index' => 'sfo.customer_email',
));
note. you will need to add a 'filter_index' to all calls to addColumn pointing to main_table.field_name
回答2:
My solution:
$collection->getSelect()
->join(
'sales_flat_order_address',
'main_table.entity_id = sales_flat_order_address.parent_id AND sales_flat_order_address.address_type="shipping"', array('sales_flat_order_address.email'
=> 'email'));
来源:https://stackoverflow.com/questions/6416864/how-to-add-customer-email-to-order-grid-in-magento-1-4