On this page I want to add the Manufacturer name directly below the name of the item, but can\'t seem to get this to work. Have tried a number of suggestions, but none seem to
$manufacturer_items = Mage::getModel('eav/entity_attribute_option')->getCollection()->setStoreFilter()
->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code');
foreach ($manufacturer_items as $manufacturer_item) :
if ($manufacturer_item->getAttributeCode() == 'manufacturer')
$manufacturer_options[$manufacturer_item->getOptionId()] = $manufacturer_item->getValue();
endforeach;
$this->addColumn('manufacturer',
array(
'header'=> Mage::helper('catalog')->__('Manufacturer'),
'width' => '100px',
'type' => 'options',
'index' => 'manufacturer',
'options' => $manufacturer_options,
));
Put this code in Gird.php file and this code in apoximate line number 58 to 63 in same file ->addAttributeToSelect('manufacturer')
Try this, assuming that you are using attribute set to create a 'manufacturer' field in Admin -> Catalog -> Manage Attributes.
Write a custom module that extend Catalog Product Block Grid /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
Create Block File: app/code/local/MageIgniter/ManufacturerGrid/Block/AdminhtmlCatalog/Product/Grid.php
class MageIgniter_ManufacturerGrid_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
{
Copy method _prepareCollection() to you custom block and update (line 58)
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('manufacturer') // added this line
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id');
Copy method _prepareColumns() to you custom block and add
$this->addColumn('manufacturer',
array(
'header'=> Mage::helper('catalog')->__('Manufacturer'),
'width' => '60px',
'index' => 'manufacturer',
'type' => 'options';
'options' => Mage::helper('manufacturergrid')->getManufacturerOption(),
));
Create Helper File: app/code/local/MageIgniter/ManufacturerGrid/Helper/Data.php
class MageIgniter_ManufacturerGrid_Helper_Data extends Mage_Core_Helper_Abstract
{
public function getManufacturerOption(){
$_opt = array();
foreach (Mage::getModel('eav/config')->getAttribute('catalog_product','manufacturer')->getSource()->getAllOptions(false,true) as $option){
$_opt[$option['value']] = $option['label'];
}
return $_opt;
}
}
Create: app/code/local/MageIgniter/ManufacturerGrid/etc/config.xml
<config>
<modules>
<MageIgniter_ManufacturerGrid>
<version>1.0.0</version>
</MageIgniter_ManufacturerGrid>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<catalog_product_grid>MageIgniter_ManufacturerGrid_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
</rewrite>
</adminhtml>
</blocks>
<helpers>
<localship>
<class>MageIgniter_ManufacturerGrid_Helper</class>
</localship>
</helpers>
</global>
</config>
Create: app/etc/modules/MageIgniter_ManufacturerGrid.xml
<?xml version="1.0"?>
<config>
<modules>
<MageIgniter_ManufacturerGrid>
<active>true</active>
<codePool>local</codePool>
</MageIgniter_ManufacturerGrid>
</modules>
</config>