I added categories unordered list on product page with the following code

        $currentCatIds = $_product->getCategoryIds();
        $categoryCollection = Mage::getResourceModel('catalog/category_collection')
                             ->addAttributeToFilter('entity_id', $currentCatIds)
                             foreach($categoryCollection as $cat){
          echo '<li> <a href="'.$cat->getUrl().'" title="'.$cat->getName().' ">'.$cat->getName().'</a> </li>';


I use some "service" categories and for this I set "not included in menu and in category list"

Is it possible to hide this "special categories" from the product detail list?


Add this to your filters:

->addAttributeToFilter('include_in_menu', array('eq'=>1))
| improve this answer | |
  • Consider adding full code snippet. – Adarsh Khatri Oct 9 '15 at 1:27

Try below code

$currentCatIds = $_product->getCategoryIds();
$categoryCollection = Mage::getModel('catalog/category')->getCollection()
        ->addAttributeToFilter('include_in_menu', array('eq'=>true))

You will need to use ->addAttributeToFilter('include_in_menu', array('eq'=>true)) which is default attribute filter function in Magento.

For addIdFilter($currentCatIds), there is default function in category resource class.

Class: Mage_Catalog_Model_Resource_Category_Collection

Function: addIdFilter($categoryIds)

Param: array $categoryIds

| improve this answer | |
  • okay cool.. what is the difference between your answer and Taylor's ? Can you justify ? – Rajeev K Tomy Oct 9 '15 at 5:02
  • Edited description in my answer – Akhilesh Patel Oct 9 '15 at 5:37

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.