2011-06-20 74 views

回答

7

副本
應用程序/代碼/核心/法師/ Adminhtml /座/銷售/訂單/ Grid.php

應用程序/代碼/本地/法師/ Adminhtml /座/銷售/訂單/ Grid.php

然後下面一行下

$collection = Mage::getResourceModel($this->_getCollectionClass());

添加

$collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email'));

然後在_prepareColumns()方法中添加

$this->addColumn('customer_email', array(
     'header' => Mage::helper('sales')->__('Customer Email'), 
     'index' => 'customer_email', 
     'filter_index' => 'sfo.customer_email', 
    )); 

音符。您將需要一個「filter_index」添加到所有呼叫addColumn指向main_table.field_name

+0

這個答案完美的作品!不過,在嘗試_extend_Mage_Adminhtml_Block_Sales_Order_Grid時遇到了問題,而不是簡單地在本地複製它。 '_prepareCollection'返回'parent :: _ prepareCollection'。如果擴展該類,則返回'parent :: _ prepareCollection'將取消定製到集合。我認爲擴展類更加優雅,可以在本地進行復制,因此如果我升級Mage內核,我會得到類中其他代碼的更新,但是如何才能使其正常工作? – BrianVPS

+0

也適用於1.5.1.0 – a1anm

1

我的解決辦法:

$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')); 
相關問題