Magento – 1.9 – Add custom column to Sales Order Create Grid

magento-1.9order-grid

I've copied

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

To

app/code/local/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php

And added ->addAttributeToSelect('brand') within _prepareCollection()

Within _prepareColumns() I have added:

$this->addColumn('brand', array(
  'header'    => Mage::helper('sales')->__('Brand'),
  'width'     => '80',
  'index'     => 'brand'
));

I now have the Brand ID in the Sales Order Create Grid.

However I want to see the brand name rather than ID (The brand is a dropdown within admin).

How do I display the option value rather than ID?
ie. "Brand Name" rather than "47"

Best Answer

I got it to work by adding the below to _prepareColumns():

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'brand');
$options = $attribute->getSource()->getAllOptions(false);
$values = array();
foreach ($options as $option){
  $values[$option['value']] = $option['label'];
}

$this->addColumn('brand', array(
  'header'    => Mage::helper('sales')->__('Brand'),
  'width'     => '80',
  'index'     => 'brand',
  'type'      => 'options',
  'options'   => $values
));
Related Topic