2

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"

2 Answers 2

1

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
));
1

Following Inchoo article on extending the order grid. And on the Atwix blog there's an article on adding a column from a different table.

You will be rewriting the Mage_Adminhtml_Order_Grid block class adding a column to the _prepareColumns method and extending the _prepareCollection method with your custom field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.