Trying to add email address into the grid in sales but once added can't search by order number. Throwing error:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous, query was: SELECT COUNT(*) FROM
sales_flat_order_grid
ASmain_table
INNER JOINcustomer_entity
ON main_table.customer_id = customer_entity.entity_id WHERE (increment_id
LIKE '%0013%')
my code:
protected function _prepareCollection()
{
$customer_entity = Mage::getSingleton('core/resource')->getTableName('customer_entity');
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()
->join(
$customer_entity,
'main_table.customer_id = '.$customer_entity.'.entity_id', array('customer_email' => 'email'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
and field definition:
$this->addColumn('customer_email', array(
'header' => Mage::helper('Sales')->__('Email'),
'width' => '100px',
'index' => 'customer_email',
'type' => 'text',
));
what to do to make it work ? To display email I can just add a column but then while I'm trying to search by email magento throwing an error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer_email' in 'where clause', query was: SELECT COUNT(*) FROM
sales_flat_order_grid
ASmain_table
WHERE (customer_email
LIKE '%custom%')