I have the following category: main category (!= root)

Main category
|- sub category 1
|- sub category 2
|- sub category 3

My navigation,

    <?php echo $_menu ?>

Now renders

Main category

How can I get it to render just the sub categories, like

Subcategory 1
Subcategory 2
Subcategory 3

(The reason I put all my categories in one main is to be able to link to mysite.com/shop for all products. Main category therefore is /shop )

1 Answer 1


You can probably do that by overwriting the file app/core/Mage/Catalog/Block/Navigation.php


<?xml version="1.0"?>


class YourCompany_Catalog_Block_Navigation extends Mage_Catalog_Block_Navigation {
    public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
    $activeCategories = array();
    foreach ($this->getStoreCategories() as $child) {
        if ($child->getIsActive()) {
            $activeCategories[] = $child;

    $activeCategoriesCount = count($activeCategories);
    $hasActiveCategoriesCount = ($activeCategoriesCount > 0);

    if (!$hasActiveCategoriesCount) {
        return '';

    $html = '';
    $j = 0;
    foreach ($activeCategories as $category) {
        foreach ($category->getChildren() as $child) { // Added this loop to bypass the first top categories
            $html .= $this->_renderCategoryMenuItemHtml(
                ($j == $activeCategoriesCount - 1),
                ($j == 0),

    return $html;


<?xml version="1.0"?>

Global overview of the files to creates: app code local YourCompany Catalog Block Navigation.php etc config.xml etc modules YourCompany_Catalog.xml

  • Are there any additional steps? Nothing happens... And I also guess you mean app > code > local ?
    – Frank
    Mar 24, 2015 at 16:19
  • Yes in app/code/local, my answer has been edited by someone else with this error. You also have to declare your new local module (I've edited my answer)
    – chris
    Mar 24, 2015 at 16:23
  • Hm still nothing. I've also refreshed my cache. I'm also sure I copy pasted everything in the right directory, as well as a find & replace for YourCompany edit: and I also had config.xml already capitalized
    – Frank
    Mar 24, 2015 at 16:28
  • I might found what I'm doing wrong. My menu is located @ page/html/topmenu.phtml (instead of /Catalog/ as your answer suggests (I guess). I guess that changes your answer?
    – Frank
    Mar 24, 2015 at 17:00
  • It is weird that nothing happened. The phtml file is not where your menu is created. It defines the custom elements of your menu but the "classic" menu creation with the categories is in the navigation.php file. My answer wasn't quite right, but I tried it today and the following works.
    – chris
    Mar 25, 2015 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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