In this post I am going to explain how to get sub-categories from parent category id in PrestaShop 1.7.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // Your Product id $id_parent_category = 3; // Fetch parent category $categoryObj = new Category($id_parent_category); // Validate category object if (Validate::isLoadedObject($categoryObj)) { $categoryList = $categoryObj->getSubCategories($this->context->language->id); if ($categoryList && count($categoryList) > 0) { foreach ($categoryList AS $key => $val) { // get sub category id $id_category = $val['id_category']; // get sub category name $name = $val['name']; // get sub category description $description = $val['description']; } } } |
Thats it! Team HiddenTechiesWrite an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!
Recent Comments