I\'m trying to add a category column to the product grid.
I\'ve modified Mage_Adminhtml_Block_Catalog_Product_Grid
.
Added the following to _prepareCollection<
to display the name o all categories you can use
$this->addColumn('category_ids',
array(
'header'=> Mage::helper('catalog')->__('Category'),
'type' => 'options',
'index' => 'category_ids',
'options' => $this->catOptions,
'renderer' => 'Your_Module_Block_Adminhtml_List_Cat',
));
in your class block
class Your_Module_Block_Adminhtml_List_Cat extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$product = Mage::getModel('catalog/product')->load($row->getEntityId());
$cats = $product->getCategoryIds();
$allCats = '';
foreach($cats as $key => $cat)
{
$_category = Mage::getModel('catalog/category')->load($cat);
$allCats.= $_category->getName();
if($key < count($cats)-1)
$allCats.= ' ,';
}
return $allCats;
}
}