开发者

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

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or 开发者_StackOverflowfavorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

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


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


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'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜