Get Category Children

Updated . Posted . Visible to the public.
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
Last edit
Posted by Michael O'Loughlin to Magento (2013-01-31 09:26)