To get all categories in magento 1.9.2.4 -
<?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 -
<?php
$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 :)