Magento 1.9 – How to Get Root Category Details

categorycategory-productsmagento-1.9

How to get root category details like name, id, URL, imageurl, description. I write some code but I don't get the description and image url. My code is

$_categories = Mage::getModel('catalog/category')->getCollection()
                 ->addAttributeToSelect('name')
                 ->addAttributeToSelect('is_active')
                 ->addUrlRewriteToResult();


foreach($_categories as $_category): 
$catUrl = $_category->getUrl($_category);
$catName = $_category->getName($_category);
$catId = $_category->getId($_category);
$catDescription = $_category->getDescription();
$catImageurl = $_category->getImageUrl();
endforeach; 

Best Answer

Try This code

     <?php

        $category = Mage::getModel('catalog/category')->load(2);
        $subCategory=($category->getResource()->getChildren($category, true));
         foreach ($subCategory as $categoryID)
         {
            $sCategory = Mage::getModel('catalog/category')->load($categoryID);
            echo $sCategory->getUrlKey();
            echo $sCategory->getName();
            echo $sCategory->getImageUrl();

         }

        ?>
Related Topic