My categories and subcategories hierarchy to a product listing page :

  • Products
    • Refrigerator
      • back-bar fridges
        • Product listing(here)

Now, what i'm trying to get is while i'm in product listing page i want to get all the parent categories and subcategories with respective links.

I got answer from this question But, i failed to get all parent items (subcategories and subcategories)

$path = $category->getPath();          
What i get is : 0(root)/2(Magento root)/444(products)

And it escapes all the middle subcategories. In my case it escaped Refrigerator/backbar fridges

  • Are you looking for only all the parent and child categories of the given category where you product is listed?
    – laketuna
    Commented Mar 8, 2015 at 5:54

3 Answers 3


this will show like breadcrum.

I know this is quite old, but I'd like to share my solution anyway as it doesn't override/clone any core files.

In your custom module add the following to your config.xml:

                        <class><Your Namespace>_<Your Module>_Model_Observer</class>

Create an Observer.php in /app/code/local///Model/

Add the following to your Observer.php:

class <Your Namespace>_<Your Module>_Model_Observer {
    public function fullBreadcrumbCategoryPath(Varien_Event_Observer $observer) {
        $current_product = Mage::registry('current_product');

        if( $current_product ) {
            $categories = $current_product->getCategoryCollection()->addAttributeToSelect('name')->setPageSize(1);
            foreach( $categories as $category ) {
                Mage::register('current_category', $category);

I hope this will help you.


Try this to get all active categories:

$categories = Mage::getModel('catalog/category')

May be this give help you a bit.


$parentCategoryId = 222;
$cat = Mage::getModel('catalog/category')->load($parentCategoryId);
$subcats = $cat->getChildren();

// Get 1 Level sub category of Parent category
foreach(explode(',',$subcats) as $subCatid)
                $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive()) {
    echo '<li><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a><li>';


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.