how to display a new root category except default category in magento

how to display a new root category except default category in magento

August 13, 2026 · Illustrated author avatarBy Stefan Bogdanescu
how to display a new root category except default category in magento

Displaying a New Root Category Except Default Category in Magento

If you’re looking to display a specific root category on certain pages of your Magento website while excluding the default menu, follow these steps:

Step 1: Create Your Custom Category

First, log into your Magento admin panel and navigate to the “Catalog” > “Categories” section. Here you can create or edit an existing top-level category.

To create a new root category:

  • Click on “Add Root Category”.
  • Enter the necessary details like name, meta information, etc.
  • Make sure it’s set as ‘Enabled’.
  • Save the category with ID 12 (or any other unique value).

Step 2: Modify Your Layout XML

Now, let’s modify your layout XML to display this specific category. You’ll need access to your theme’s layout files.

Navigate to your local Magento installation directory > app/design/frontend/[your_package]/[your_theme]/layout. Find the XML file associated with the page where you want to show this category (e.g., catalog.xml for product list pages).

Add or modify the following code in the appropriate section:

<reference name="content">
    <block type="catalog/navigation" name="catalog.navigation.root" before="-" template="catalog/navigation/root.phtml"/>
</reference>

This tells Magento to include a new navigation block (catalog/navigation/root) within your content area.

Step 3: Create the Root Template

Next, create a new file named ‘root.phtml’ in the following directory:

app/design/frontend/[your_package]/[your_theme]/template/catalog/navigation/

In this root.phtml file, paste the modified code below:

<?php
$category = Mage::getModel('catalog/category');
$tree=$category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
$arr = array();
if ($ids){
foreach ($ids as $id){
  $cat = Mage::getModel('catalog/category');
  $cat->load($id);
  $arr[$id]=$cat->getName();
}
}

$root_id = '12'; // Replace with your custom category ID
$collection = Mage::getModel('catalog/category')->getCollection()
      ->addAttributeToFilter('entity_id', array('eq' => $root_id))
      ->addAttributeToSort('position', 'ASC');

echo '<ul class="jetmenu blue">';
foreach($collection as $cat){
    echo '<li><a href="'.$cat->getURL().'" />'.$cat->getName().'</a>';
    $subcategory_html=GetSubcategory($cat_id);
    echo $subcategory_html;
    echo '</li>';
}
echo '</ul>';
?>

This code retrieves the specific root category with ID 12 and displays its subcategories.

Step 4: Refresh Your Cache

After saving all changes, make sure to refresh your cache in Magento admin under System > Configuration > Advanced. This ensures that your updates take effect immediately without waiting for a page refresh.

That’s it! Now you should see only the custom root category with ID 12 displaying on the specified pages of your Magento website, while the default menu remains hidden.

Remember to customize the code according to your specific needs and theme structure. For more advanced layout manipulation techniques, consider exploring Laravel Company’s guide to Magento layout updates.

If you encounter any further issues or have questions about optimizing your Magento site performance and user experience, feel free to reach out!

Catalog Themes Admin SEO

Our network