I want to get all categories in store. so if set any category option not including in navigation menu the category not showing in list tree.

So My question: how i can get all tree categories both including and not including in navigation menu.

I've use below function :

public function getStoreCategories()
  $helper = Mage::helper('catalog/category');
  return $helper->getStoreCategories();

1 Answer 1


To get all categories in magento -

<?php  $_helper = Mage::helper('catalog/category'); $_categories = $_helper->getStoreCategories(); if (count($_categories) > 0){
    foreach($_categories as $_category){
        $_category = Mage::getModel('catalog/category')->load($_category->getId());
        $_subcategories = $_category->getChildrenCategories();
        if (count($_subcategories) > 0){
            echo $_category->getName();
            echo $_category->getId();      
            foreach($_subcategories as $_subcategory){
                 echo $_subcategory->getName();
                 echo $_subcategory->getId();
    } } ?>

To get a single category we should use -

$category = Mage::getModel('catalog/category')->load(4); //4 = categoryID
$subcategories = $category->getChildrenCategories();
if (count($subcategories) > 0){
    echo $category->getName();
    foreach($subcategories as $subcategory){
         echo $subcategory->getName();

Hope this helps :)

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.