Thursday, 21 July 2011

Magento Category List

To display all root category list add this code to your file where you want display category.

$category = Mage::getModel('catalog/category')->load(2);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{
 foreach ($subcategory as $sub)
    {
        $sub1 = Mage::getModel('catalog/category')->load( $sub);
        echo $sub1->getUrl();
        echo $sub1->getName();
        echo $sub1->getImageUrl();
    }
}

1 comment:

  1. Nice Explanation.
    This is very helpful for me.
    Thanks

    ReplyDelete