Get Categories Which are visible in Main Navigation in magento 1.9.

marked as duplicate by Murtuza Zabuawala, Siarhey Uchukhlebau, David Verholen, Raphael at Digital Pianism, brentwpeterson Dec 27 '16 at 18:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    $collection = Mage::getResourceModel('catalog/category_collection')
        ->addAttributeToFilter('is_active', 1) //only active categories
        ->addAttributeToFilter('include_in_menu', 1); //only categories included in menu

   foreach ($collection as $category) {


Used this answer: https://magento.stackexchange.com/a/19272/18764

    $rootcatId= Mage::app()->getStore()->getRootCategoryId();
    $categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
    function  get_categories($categories) {
        $array= '<ul>';
        foreach($categories as $category) {
            $cat = Mage::getModel('catalog/category')->load($category->getId());
            $count = $cat->getProductCount();
            $array .= '<li>'.
            '<a href="' . Mage::getUrl($cat->getUrlPath()). '">' .
                      $category->getName() . "(".$count.")</a>\n";
            if($category->hasChildren()) {
                $children = Mage::getModel('catalog/category')->getCategories($category->getId());
                 $array .=  get_categories($children);
            $array .= '</li>';
        return  $array . '</ul>';
    echo get_categories($categories); 

You will get all the categories and child categories with product quantity which are included in main navigation. Hope, it will be help

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