1/05/2011

How to get sub category list of a particular category in magento

To get all subcategory list under a particular category you need to know the category id of that particular id, then you can get the subcategory .In the below example I have taken My category id is 69.

<?php
$category = Mage::getModel('catalog/category')->getCategories(69);
foreach($category as $_category){
$currentCat = Mage::getModel('catalog/category')->load($_category->getId());
?>
<li><a href="<?php echo $currentCat->getUrl()?>"><?php echo $currentCat->getName();?></a></li>
<?php
}
?>

1 comment:

  1. thanx i got the category but now i write this kind of code now i want to put that category in this dropdown menu.

    $fieldset->addField('category', 'select', array(
    'label' => Mage::helper('zonpages')->__('Option Category'),
    //'title' => Mage::helper('zonpages')->__('Status'),
    'name' => 'category',
    'required' => true,
    'options' => array(

    please help me

    ReplyDelete