8

I have tried to get all sub categories which are not include in navigation menu but those are being active, of current category in list page.

$children = Mage::getModel('catalog/category')->getCategories(10); //10 current category id

Even this category collection also return only subcategories which are include in navigation menu.

How to get category which isn't include in navigation menu?

11

Try this:

$collection = Mage::getResourceModel('catalog/category_collection')
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('is_active', 1) //only active categories
    ->addAttributeToFilter('include_in_menu', 0) //only categories not included in menu
    ->addAttributeToFilter('parent_id', 10)//get only subcategories of the category with id 10
    ->addAttributeToSort('position')//sort by position
;

foreach ($collection as $category) {
    //do something with $category
}
  • It also doesn't return the category which isn't not showing in menu @marius – DRAJI May 5 '14 at 8:29
  • 1
    @DRAJI. hmmm...it should. Make sure your indexes are up to date. – Marius May 5 '14 at 8:34
  • Sorry this also "$collection = Mage::getResourceModel('catalog/category_collection')" doesn't return those categories – DRAJI May 5 '14 at 9:55
  • @DRAJI. Then It might be something wrong with your category tree. Corrupted data maybe. Some values for path field might be wrong. Or parent ids may be wrong. – Marius May 5 '14 at 10:00

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.