Search This Blog

Friday, 29 June 2012

Magento: Get Child Categories by Category ID

  
$category_model = Mage::getModel('catalog/category'); //get category model
$_category = $category_model->load($categoryid); //$categoryid for which the child categories to be found       
$all_child_categories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id



OR

$children = Mage::getModel('catalog/category')->getCategories(4);
//4 is parent category ID
foreach ($children as $category) {
    echo $category->getName();
}

1 comment: