1) Parent category
//Parent category $parentCategoryId = 107; $cat = Mage::getModel('catalog/category')->load($parentCategoryId); $subcats = $cat->getChildren();
2) Get 1 Level sub category of Parent category.
//Get 1 Level sub category of Parent category foreach(explode(',',$subcats) as $subCatid){ $_category = Mage::getModel('catalog/category')->load($subCatid); if($_category->getIsActive()) { echo ''; } }
3) Get 2 Level sub category of Parent sub category.
// Get 2 Level sub category of Parent sub category foreach(explode(',',$subcats) as $subCatid) { $_category = Mage::getModel('catalog/category')->load($subCatid); if($_category->getIsActive()) { echo '
- getName().'" category">'.$_category->getName().'';
$sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
$sub_subcats = $sub_cat->getChildren();
foreach(explode(',',$sub_subcats) as $sub_subCatid){
$_sub_category = Mage::getModel('catalog/category')->load($sub_subCatid);
if($_sub_category->getIsActive()) {
echo '
- getName().'" category">'.$_sub_category->getName().' '; } } echo '
4) Get 3 Level sub sub category of Parent sub sub category
// Get 3 Level sub sub category of Parent sub sub category foreach(explode(',',$subcats) as $subCatid) { $_category = Mage::getModel('catalog/category')->load($subCatid); if($_category->getIsActive()) { echo '
- getName().'" category">'.$_category->getName().'';
$sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
$sub_subcats = $sub_cat->getChildren();
foreach(explode(',',$sub_subcats) as $sub_subCatid)
{
$_sub_category = Mage::getModel('catalog/category')->load($sub_subCatid);
if($_sub_category->getIsActive()) {
echo '
- getName().'" category">'.$_sub_category->getName().' '; $sub_sub_cat = Mage::getModel('catalog/category')->load($sub_subCatid); $sub_sub_subcats = $sub_sub_cat->getChildren(); foreach(explode(',',$sub_sub_subcats) as $sub_sub_subCatid) { $_sub_sub_category = Mage::getModel('catalog/category')->load($sub_sub_subCatid); if($_sub_sub_category->getIsActive()) { echo '
- getName().'" category">'.$_sub_sub_category->getName().' '; } } } } echo '
// $sub_subCatid this is sub category id . means if you want 4 level than it will take 3 level subcategory Id. $sub_sub_cat = Mage::getModel('catalog/category')->load($sub_subCatid); $sub_sub_subcats = $sub_sub_cat->getChildren(); foreach(explode(',',$sub_sub_subcats) as $sub_sub_subCatid) { $_sub_sub_category = Mage::getModel('catalog/category')->load($sub_sub_subCatid); if($_sub_sub_category->getIsActive()) { echo '
No comments:
Post a Comment