Get Category Children

public function getCategories() 
{
    if (!$this->categories) {
        $categoryId = $this->getData('parent_category_id');
        $parentCategory = Mage::getModel('catalog/category')->load($categoryId);

        $categoryCollection = $parentCategory->getCollection();
        $categoryCollection->addAttributeToSelect('url_key')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('image')
            ->addAttributeToFilter('is_active', 1)
            ->addAttributeToFilter('include_in_menu', 1)
            ->addIdFilter($parentCategory->getChildren())
            ->setOrder('position', Varien_Db_Select::SQL_ASC)
            ->joinUrlRewrite();

        $this->categories = $categoryCollection;
    }
    return $this->categories;
}

Michael O'Loughlin Over 11 years ago