I have created a custom sales order attribute using the installer of my custom mage module like this:

$installer = new Mage_Sales_Model_Mysql4_Setup;
    $installer->addAttribute('order', 'sales_rep', array
        'type'            => 'varchar',
        'backend_type'    => 'varchar',
        'frontend_input'  => 'varchar',
        'is_user_defined' => true,
        'label'           => 'Sales Rep',
        'visible'         => true,
        'required'        => false,
        'user_defined'    => false,
        'searchable'      => false,
        'filterable'      => false,
        'comparable'      => false,
        'default'         => ''
catch (Exception $ex) { }

This attribute value is normally set when orders are created programatically.

Now, I would like to show this attribute on the sales order grid, so I have duplicated this file:




and amended the _prepareCollection() method like this:

protected function _prepareCollection()
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $select = $collection->getSelect();
        'order' => Mage::getModel('core/resource')->getTableName('sales/order')),
        array('sales_rep' => 'sales_rep')
    return parent::_prepareCollection();

I've verified this is generating the correct SQL by doing this:


and it outputs:

SELECT main_table.*, order.sales_rep FROM sales_flat_order_grid AS main_table LEFT JOIN sales_flat_order AS order ON order.entity_id=main_table.entity_id

I've also verified that this returns result by executing the above query in phpMyAdmin and I get the following:

enter image description here

Having done all the test, I proceeded to update the _prepareColumns() method on Grid.php by adding the following (just before status):

$this->addColumn('sales_rep', array(
    'header' => Mage::helper('sales')->__('Sales Rep'),
    'index' => 'sales_rep',
    'type'  => 'options',
    'width' => '70px'

Now, when I refresh the sales order grid in magento backend, I am not getting any values back, it looks like this:

enter image description here

Any ideas what I am doing wrong here?

  • Is possible to workout, the manually change added attribute values like if order placed I need manually change the attribute value in sales order grid, first of all how can I creat attribute and how can I Integrate to sales order table,, Is possible?
    – zus
    Commented Sep 27, 2017 at 11:25
  • Is your Issue Solved?
    – zus
    Commented Oct 5, 2017 at 11:18
  • yes, see below accepted answer.
    – Latheesan
    Commented Oct 5, 2017 at 12:01
  • could you please help @ magento.stackexchange.com/q/196004/57334
    – zus
    Commented Oct 5, 2017 at 12:14

1 Answer 1


Error in column code use below code.

$this->addColumn('sales_rep', array(
    'header' => Mage::helper('sales')->__('Sales Rep'),
    'index' => 'sales_rep',
    'type'  => 'text',
    'width' => '70px'

you have used 'type' => 'options' and not define options there

  • Ah man, all that effort and one silly typo ruins it. Thanks, spot on.
    – Latheesan
    Commented Mar 2, 2016 at 13:08
  • If it is solution you can mark as accepted Commented Mar 2, 2016 at 13:11
  • It shows me this error, ' Column not found: 1054 Unknown column 'order.sales_executive' in 'field list' '. Any help? @PrashantValanda Commented Dec 9, 2016 at 11:56
  • Have you left join attribute in collection as in question Commented Dec 9, 2016 at 12:25
  • I did the above thing. @PrashantValanda Commented Dec 9, 2016 at 12:37

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.