SQLSTATE[42S22]: Column not found: 1054 Unknown column 'main_table.sfo.customer_email' in 'where clause' [closed]-Collection of common programming errors
The Smart DudeHelp. I have been struggling with this error for a few days now and have yet to find an answer. I am trying to add a few columns to the orders grid in Magento 1.6.2 I followed the instructions from: [http://www.milessebesta.com/web-design/magento-customize-backend-order-grid-to-have-sku-e-mail-address-and-phone-number/][1]
Here is the error message:
SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘main_table.sfo.customer_email’ in ‘where clause’
Here is my code:
protected function _getCollectionClass() { return 'sales/order_collection'; } protected function _prepareCollection() { $collection->getSelect()->group('main_table.entity_id'); $collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email','sfo.weight','sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status','sfo.base_grand_total','sfo.grand_total')); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('real_order_id', array( 'header'=> Mage::helper('sales')->__('Order *'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id', 'filter_index' => 'sfo.increment_id', )); if (!Mage::app()->isSingleStoreMode()) { $this->addColumn('store_id', array( 'header' => Mage::helper('sales')->__('Purchased From (Store)'), 'index' => 'store_id', 'type' => 'store', 'store_view'=> true, 'display_deleted' => false, 'width' => '40px', )); } $this->addColumn('customer_email', array( 'header' => Mage::helper('sales')->__('Customer Email'), 'index' => 'customer_email', 'type' => 'text', 'filter_index' => 'sfo.customer_email', 'width' => '50px', )); return parent::_prepareColumns(); }
BornietCheck your database to see the actual name of the column you’re referring to. As Mysql says in its error: the column you’re addressing doesn’t exist.