Call Category function
$categories = $this->getTreeCategories(2, false);Get All categories array tree view
print_r($categories);
function getTreeCategories($parentId, $isChild) {
$allCats = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('is_active', '1')
->addAttributeToFilter('include_in_menu', '1')
->addAttributeToFilter('parent_id', array('eq' => $parentId));
$subcat = ($isChild) ? " -- " : "";
foreach ($allCats as $category) {
$options[] = array(
'label' => Mage::helper('jaydip_attrfiltercount')->__($subcat.iconv(mb_detect_encoding($category->getName(), mb_detect_order(), true), "UTF-8", $category->getName())),
'value' => $category->getId()
);
$subcats = $category->getChildren();
if ($subcats != '') {
$options[] = $this->getTreeCategories($category->getId(), true);
}
}
$optiondata = array();
foreach ($options as $option):
if(isset($option[0])){
foreach ($option as $value):
$optiondata[] = array(
'label' => $value['label'],
'value' => $value['value']
);
endforeach;
}else{
$optiondata[] = array(
'label' => $option['label'],
'value' => $option['value']
);
}
endforeach;
return $optiondata;
}