In my Magento Sales admin grid i would like to have an email and country so I created a code to make it possible:

    protected function _prepareCollection()
        $collection = Mage::getResourceModel($this->_getCollectionClass());
            'main_table.entity_id = sales_flat_order_address.parent_id',
        ->where("sales_flat_order_address.address_type =  'billing'");
            'order.entity_id = main_table.entity_id',
        return parent::_prepareCollection();

and to display columns:

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

    $this->addColumn('country_id', array(
        'header' => Mage::helper('sales')->__('Country Id'),
        'index' => 'country_id',
        'width' => '25px',
        'align' => 'center',
        'filter_index' => 'sales_flat_order_address.country_id',

once I added and saved this code everything seems to work until trying to search order by ID (increment_id) then Magento throws me an error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sales_flat_order.increment_id' in 'order clause', query was: SELECTmain_table.*,sales_flat_order_address.telephone,sales_flat_order_address.city,sales_flat_order_address.postcode,sales_flat_order_address.country_id,order.customer_emailFROMsales_flat_order_gridASmain_table INNER JOINsales_flat_order_addressON main_table.entity_id = sales_flat_order_address.parent_id LEFT JOINsales_flat_orderASorderON order.entity_id = main_table.entity_id WHERE (sales_flat_order_address.address_type = 'billing') ORDER BY sales_flat_order.increment_id ASC LIMIT 20

so I checked sales_flat_order to make sure there is a column named increment_id and it is there but it does not contain (it seems) correct increment_id but something ... else ... series of numbers anyhow not resembling expected number.

What I've done wrong ... please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.