Leon van der Veen
Leon van der Veen

Reputation: 1672

magento subcategories in sidebar

I'm using Magento with an horizontal menu. This menu shows all parent categories. What I want is to show the subcategories of the clicked parent category.

How can i realise this?

Thanks in advance!

Upvotes: 0

Views: 1258

Answers (1)

MagePsycho
MagePsycho

Reputation: 2004

You can use the following code in order to get sub-categories in the parent category page:

<?php
$parentCategory     = Mage::registry('current_category');
if($parentCategory){
    $catId              = $parentCategory->getId();
    $category           = Mage::getModel('catalog/category')->load($catId);
    $childCategories    = $category->getChildrenCategories();
    foreach($childCategories as $_category){
        print_r($_category->getData());
    }
}

Hope this helps.

Thanks

Upvotes: 1

Related Questions