How to add customer email to order grid in magento 1.4 [closed]

扶醉桌前 提交于 2019-12-11 04:08:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!