Roy Vincent Niepes

Blog and Portfolio

Posted on by

Adding product type column in manage categories in category product tab


Adding product type column in manage categories in category product tab

Magento has this column already in manage products grid, however it wasn’t included in category product tab in manage categories.
In the magento site that I’ve developed, client requests to add a filter for product type in category product tab, because most of the products in that site was a grouped product and most of the simple product aren’t visible individually. So the client is having a hard time finding the products he wanted to include in a category.

Here’s how I did it.

The file that you need to modify for the category product is located in
/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php

Simply create a local copy of it, so that it will not be affected when updaing magento

The local copy should be located with this path
/app/code/local/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php

Now lets start editing this file.

Find _prepareCollection function

we only need to add this one line of code
->addAttributeToSelect('type_id')

just simply add this next to price or in any order, doesn’t matter anyway.
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->addAttributeToSelect('type_id')

Next is in the _prepareColumns function

we just have to add this piece of code

$this->addColumn('type',
array(
'header'=> Mage::helper('catalog')->__('Type'),
'width' => '120',
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));

In my end I’ve added it next to
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));

After doing the steps above, just re-index your site to see the result .

You will see that a new column has been added to it.

From this
from

to this
to

comments powered by Disqus