I am trying to add the Customer Email to our adminhtml order grid. We are overriding the code in Mage/core in this file: app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

In PrepareColumns we add

$this->addColumn('customer_email', array(
    'header'    => Mage::helper('Sales')->__('Email'),
    'width'     => '100px',
    'index'     => 'customer_email',
    'type'        => 'text',


And in _prepareCollection we added this

$customer_entity = Mage::getSingleton('core/resource')->getTableName('customer_entity');
               'main_table.customer_id = '.$customer_entity.'.entity_id', array('customer_email' => 'email'));

The good news is, that it does add the email column

My question: Now the only problem is that when we enter an order id, or sku as filter that the result is the Magento error page .... So something is still going wrong here

What are we forgetting? Or what is the best code for Magento 1.8 to add the Email address in the order grid?

  • can you please look in var/report/error_id and tell us what is the error? it might help us to solve issue easily.
    – Mr_Green
    Apr 18, 2014 at 12:00
  • a:5:{i:0;s:104:"SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous";i:1;s:7011:"
    – snh_nl
    Apr 18, 2014 at 12:02
  • This isn't an direct answer to your question, but if you are looking to add the customer email address to your shop, please take a look at github.com/mage-eag/mage-enhanced-admin-grids Apr 18, 2014 at 17:40

3 Answers 3


Just copy Grid.php to app/code/local/Mage/Adminhtml/Block/Sales/Order/ Then append sales_flat_order table to collection

 protected function _prepareCollection()
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $collection->getSelect()->join('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('customer_email'));
        return parent::_prepareCollection();

And a addColumn to _prepareColumns()

 $this->addColumn('customer_email', array(
    'header' => Mage::helper('sales')->__('Payment method'),
    'index' => 'customer_email',
    'filter_index' => 'sales_flat_order.customer_email',

More details can be find here.

  • HI. This is not working, we keep getting the error (after entering filter for example an order id) a:5:{i:0;s:104:"SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous";i:1;s:7011:"#0
    – snh_nl
    Apr 18, 2014 at 13:37
  • Bottom line is: this code shows the email, but as an effect we cannnot filter
    – snh_nl
    Apr 18, 2014 at 13:37
  • 3
    Addition of filter_index fixed the problem
    – snh_nl
    Apr 18, 2014 at 14:09
  • plz up my answer
    – Amit Bera
    Apr 18, 2014 at 14:13
  • ? Addition of filter_index fixed the problem
    – snh_nl
    Apr 20, 2014 at 18:35

This really solved our problem and more!!!


This really improved our Magento ways of Working. Should be default.


our observer.php file


class Excellence_Ordergrid_Model_Observer {

     *  Varien_Event_Observer $observer
     * call the function coreBlockAbstractToHtmlBefore handles our event to the observer
    public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer) {
        /** @var $block Mage_Core_Block_Abstract */
        $block = $observer->getEvent()->getBlock();
        if ($block->getId() == 'sales_order_grid') {
            $block->addColumnAfter('email', array(
                    'header' => Mage::helper('Sales')->__('Email'),
                    'width' => '110px',
                    'index' => 'email',
                    'type' => 'text',
                ), 'full_address');

    public function salesOrderGridCollectionLoadBefore(Varien_Event_Observer $observer) {
        $collection = $observer->getEvent()->getOrderGridCollection();
        $select = $collection->getSelect();  
        $select->joinLeft(array('mail' => $collection->getTable('sales/order_address')), 'mail.entity_id=main_table.entity_id', array('email' => 'email'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.