Posted by

Adding product type column in manage categories in category product tab

Magento is one of popular the platform for ecommerce, packed with features that the sellers need. But even with all of its features to offer, some clients can always come up of another idea of feature.

Since most of their products are grouped, finding a product they wanted to in a category is giving them a hard time. So they asked for another column where they can use to filter. In my case was to add product type column.

Sharing is caring so 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 whenever magento is updated.

/app/code/local/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php

Now lets start editing this file.

Find _prepareCollection function and add this one line of code

->addAttributeToSelect('type_id')

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 and 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.

From this

To this

That’s it! Happy coding.