开发者

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

开发者 https://www.devze.com 2023-03-14 17:13 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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

精彩评论

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

关注公众号