Php – Magento display subcategory of specific current parent category PHP

categoriesmagentoPHP

I'm trying to display brands on my store. I sell both men and women clothing so I have two separate brand categories.

My category structure looks like this:

Men
Brands
x-brand
Women
Brands
y-brand

I would like to display the brand of the product.

I found this code:

$children = Mage::getModel('catalog/category')->getCategories(10);
foreach ($children as $category) {
    echo $category->getName();
}

However, it works for only one category and displays all subcategories in the parent category not the one owned by the product.

How can I modify this to show the subcategory of the current brand category.

I hope this made sense and I appreciate any help!

Best Answer

To display sub-category listing for a give category

$_category = Mage::registry('current_category');

$subcategories = Mage::getModel('catalog/category')->getCategories($_category->getId());

foreach ($subcategories as $subcategory){
     print_r($subcategory->getData()
}

See more @ Magento: Display sub-category list

Related Topic