How to get all Sub-category list by a main category Id in magento..


<?php
$category = Mage::getModel('catalog/category')->load(7); // 7 is the ID of Main Category
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{

foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load( $sub);?>
<a href="<?php echo $sub1->getUrl();?>"><span>
<?php echo $sub1->getName();

}?>
<?php }?>

for more maento tutorial visit: http://blog.free-extension.com/

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: