Friday, 7 August 2015

Get category as thery are shown in admin magento


Get category as thery are shown in admin magento

<?php
$categoryCollection = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id', 2)->addAttributeToSort('position');
    foreach($categoryCollection as $_subcategoryCollection):
        $categoryId = $_subcategoryCollection->getEntityId();
        $categoryName = Mage::getModel('catalog/category')->load($categoryId);
        if($categoryName->getIsActive() == 1){
?>
           <li><a href="<?php echo $categoryName->getUrl(); ?>"><?php echo $categoryName->getName(); ?></a></li>

<?php   endif;
endforeach;
?>

No comments: