Monday 18 August 2014

how to get all category and sub to sub category in a array in magento

<?php
/*get all category  */
$cat_id=array();
$pro_id=array();
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('id')
->addAttributeToSelect('is_active');

foreach ($categories as $category)
{
    if ($category->getIsActive()) {
        $entity_id = $category->getId();
        array_push($cat_id, $entity_id );//push all category id  in a array
    }
}
?>

No comments:

Post a Comment