I'm trying to add a custom category attribute to the category collection:

$product = Mage::getModel('catalog/product');
$categories = $product->getResource()

However, some_custom_attribute doesn't get included to the collection data:

[4] => array(11) {
["entity_id"] => string(4) "1164"
["entity_type_id"] => string(1) "3"
["attribute_set_id"] => string(1) "3"
["parent_id"] => string(4) "1151"
["created_at"] => string(19) "2015-04-14 06:19:05"
["updated_at"] => string(19) "2015-04-14 06:19:05"
["path"] => string(13) "1/2/1151/1164"
["position"] => string(1) "3"
["level"] => string(1) "3"
["children_count"] => string(1) "0"
["product_id"] => string(6) "106224"

How can I add the some_custom_attribute to the result?

  • If some_custom_attribute is a new attribute, you need to rebuild the category flat index before it is included in collections – Fabian Schmengler Sep 30 '15 at 15:18

try this code (it works for me)

$_categoryCollection = Mage::getResourceModel('catalog/category_collection')

This code is not working. So you can use below code as alternatively.

$product = Mage::getModel('catalog/product');

Get category ids of product

$CategoryIds = $product->getResource()

Load category collection

$collection= Mage::getResourceModel('catalog/category_collection');

Add filter category collection by categories ids

$collection->addAttributeToFilter('entity_id',array('in' => implode(',',$CategoryIds)));

Add a custom category attribute to the category collection:


  • Unfortunately, the attribute is not displayed or added. I tried to add a system default attribute, no luck. – user1240207 Sep 30 '15 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.