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

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

From this

 

To this

 

Happy Coding Mate!