Sometimes, if you use custom collection with join tables:


protected function _prepareCollection()
{
$collection = Mage::getModel('sales/order_item')->getCollection()
;
$collection->getSelect()->join( array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.order_id',array('sfo.increment_id', 'sfo.status', 'sfo.shipping_description', 'sfo.base_shipping_amount'));
$collection->getSelect()->join( array('e'=>'catalog_product_entity'), 'main_table.sku = e.sku', array('e.sku'));

$this->setCollection($collection);
return parent::_prepareCollection();
}

you’ll get an error:
‘SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘created_at’ in where clause is ambiguous’

To avoid that, use this:

$this->addColumn('created_at',
            array(
                'header'=> Mage::helper('adpreorder')->__('Date'),
                'width' => '50px',
                'type'  => 'date',
                'index' => 'created_at',
				'filter_index' => 'main_table.created_at'
        ));	

Leave a reply

Your email address will not be published.