search
top

Get child categories in Magento

Hello All,

I am writing here a script for getting all the child categories of the required category id


<?php	

	$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

?>

Hope this is useful

11 Responses to “Get child categories in Magento”

  1. Mage says:

    This will not count the disabled subcategories, do you have any trick for that?

  2. Sevs says:

    Hello… is it possible to arrange the child categories according to its order in the admin panel? Thank you so much! :)

  3. Nisha says:

    Didn’t get the code properly. I want to display all categories and all their subcategories to the end level. Can you provide some help?

    Regards,

    Nisha

  4. Jeroen says:

    Nice one! Thanks!

  5. Thank you very much! It helped me a lot to filter categories where i wanna print an Ad!

  6. fox says:

    thanks a lot!

  7. bingo says:

    thanks !

Leave a Reply

top