cancel
Showing results for 
Search instead for 
Did you mean: 

Category used as menu doesn't show children

Category used as menu doesn't show children

In my website I need to have two different categories as two different menus. In my theme there is the possibility to have only one menu in the sidebar and non on the header so I've done some changes to add a menu in header

I'm trying to show two different categories that are inside the same root category

so the structure looks like this

Root Category
 - Menu 1
     - Submenu 1
     - Submenu 2

 - Menu 2
     - Submenu a
         -Submenu a1
     - Submenu b
         -Submenu b1

Now the problem is:

The first menu is okay, I can show all the pages that are in there without any problem using the Root category as the category used for the sidebar menu.

To show the second menu I've used this code, (in header.php)

<?php echo "<div class=topmenu style='display: inline-flex;'>";
              $root_category = Mage::getModel('catalog/category')->load(3); // Put your root category ID here.
              $subcategories = $root_category->getChildren();


              foreach(explode(',',$subcategories) as $subcategory) {
                    $category = Mage::getModel('catalog/category')->load($subcategory);
                    echo '<div class=sottomenu style="width: 99px; background: #FFC100; min-height: 30px;"><a href="'.$category->getURL() .'" style="color: black; text-decoration: none; font-weight: 600; font-size: 9pt; margin-top: 6px; margin-left: 19px; position: absolute;" />'.$category->getName().'</a></div>';
              }
              echo "</div>";
        ?>

With this code I can show only the  "- Submenu A " and "- Submenu B" but not the "- Submenu a1" and "-submenu b1"