1
votes

I have added a new column (exported)in sales_flat_order and add at files at this location:

app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

protected function _prepareCollection()
{
 $collection = Mage::getResourceModel($this->_getCollectionClass())
    ->addAttributeToSelect('*')
    ->joinAttribute('exported','sales/order','sales_flat_order.entity_id',null,'left');
}

protected function _prepareColumns()
{
 $this->addColumn('exported', array(
            'header' => Mage::helper('sales')->__('Exported'),
            'index' => 'exported',
            'type'  => 'checkbox',
            'name'  =>'exported',
            'value'    =>$this->getExported()==1 ? 'true' : 'false',
          ));
  }

after that it showing on order grid in admin site,but it is not showing value and name,

I am new in magento,so please help me , stuck from 2 days. Thanks for Assistance.

1

1 Answers

0
votes

The method _prepareCollection() uses sales_flat_order_grid table as asource, thus you have to add the column to sales_flat_order_grid table and update the values of that column from the appropriate column of sales_flat_order table.

In this case, Magento will automatically update this column in sales_flat_order_grid table for future orders.

The better way to display the boolean column is Yes/No renderer. Use the following code for this in _prepareColumns() method

 $this->addColumn('exported', array(
            'header' => Mage::helper('sales')->__('Exported'),
            'index' => 'exported',
            'type'  => 'options',
            'width' => '70px',
            'options' => array(
                1  => Mage::helper('sales')->__('Yes'),
                0  => Mage::helper('sales')->__('No'),
            ),
        ));

There are some other useful articles about cutomizing order grid. Check out the links below: