How to get all category of a magento store


Posted on 02 Jun 15 by Vickey

By using below code we can get all category which is come on level 2 if we remove level filter then it will return all parent category and base category

$categories = Mage::getModel('catalog/category')->getCollection()

foreach ($categories as $category)
        $name = $category->getName();
        $url_path = $category->getUrl();


if you want to get child categories of a category then you can use this code

$children = Mage::getModel('catalog/category')->getCategories(10);

here 10 is the parent category id

If this post help you reduce time to develop, you can help me to maintain this website :)