Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:03:47+00:00 2026-06-13T10:03:47+00:00

This is my category tree: Cat_1 (This is the parent category with ID 4)

  • 0

This is my category tree:

Cat_1 (This is the parent category with ID 4)
    Subcat_1
    Subcat_2
        Subsubcat_1
        Subsubcat_2
    Subcat_3
        Subsubcat_3
        Subsubcat_4
    Subcat_4

I tried this code to retrieve this category tree but i only came to the level of the subcats. I need one level deeper.

<?php
$cat = Mage::getModel('catalog/category')->load(4);
$subcats = $cat->getChildren();

foreach(explode(',',$subcats) as $subCatid)
{
  $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive()) {
    $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 '<li class="sub_cat"><a href="'.$_sub_category->getURL().'" title="View the products for the "'.$_sub_category->getName().'" category">'.$_sub_category->getName().'</a></li>';
          }
     }
  }
}
?>

Can someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:03:48+00:00Added an answer on June 13, 2026 at 10:03 am

    Try this.

    <?php
    $cat = Mage::getModel('catalog/category')->load(4);
    $subcats = $cat->getChildren();
    
    foreach(explode(',',$subcats) as $subCatid)
    {
      $_category = Mage::getModel('catalog/category')->load($subCatid);
      if($_category->getIsActive()) {
        echo '<ul><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a>';
        $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 '<li class="sub_cat"><a href="'.$_sub_category->getURL().'" title="View the products for the "'.$_sub_category->getName().'" category">'.$_sub_category->getName().'</a></li>';
                  $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 '<li class="sub_cat"><a href="'.$_sub_sub_category->getURL().'" title="View the products for the "'.$_sub_sub_category->getName().'" category">'.$_sub_sub_category->getName().'</a></li>';
                    }
                  }
               }
         }
         echo '</ul>';
      }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A category tree like this: root_1 sub_1 sub_2 ... to sub_20 Every document has
this is the code where i create tree in telerik mvc. Now i want
This is the file tree: /problem/ /problem/index.php index.php category.php somefile.php I have this 2
I have a category tree in XML like <cat name='cat_1' id='1'> <cat name='cat_2' id='2'>
I want to design a new category this category will be separated from the
I have a performance counter category. The counters in this category may change for
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
I have this table: fourn_category (id , sub) I am using this code to
I have some codes like this: cats = Category.objects.filter(is_featured=True) for cat in cats: entries
in this page http://api.jquery.com/category/effects/ when you put 'up'(keyboard) and 'down',then put 'enter',it will go

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.