Magento Coding Solutions

Magento category programmatically tree view



$cat_mod = Mage::getModel('catalog/category')->load(2);
    $helper = Mage::helper('catalog/category');
    $_main_categories=$helper->getStoreCategories();
    echo cateList($_main_categories,0);
   
    function cateList($_main_categories,$out){
        $i=0;
           
        $cathtml='';
        //print_r($_main_categories);
        $lable='';
        foreach($_main_categories as $_category){
             if ($_category->getIsActive()){
               
                while($i<$out){
                    $space .= '   ';
                    $i++;
                }
                ?>
               
                               
                $children = $_category->getChildren();
       
                $childrencount = $children->count();
                $hasChildren = $children && $children->count();
                if($hasChildren && $children->count())
                {
                    //echo "--->";
                    $out++;
                    cateList ($children,$out);
                    $out--;
                }
            }
           
           
           
   


























  
}
  


























 






















































      
        //return "df".$cathtml;
   
    }

?>

No comments:

Post a Comment