How to get full sub-categories tree from root category id in PrestaShop 1.7

In this post I am going to explain how to get full sub-categories tree from root category id in PrestaShop 1.7.

// Set your root category id
$root_category_id = 2;

// Set language id
$language_id = $this->context->language->id;

// Get category tree for given root category
$category_tree = Category::getNestedCategories($root_category_id, $language_id);

// Print category array and find the "children" element in each category
echo "<pre>";
print_r($category_tree);
echo "</pre>";

Thats it!

1 Comment

  1. Perfectly described. Thanks for sharing such a useful article.

Leave a Reply

Your email address will not be published. Required fields are marked *