In this post I am going to explain how to get sub-categories from parent category id in PrestaShop 1.7.
// 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!
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!



April 27, 2020 at 8:52 am
Where to show this code, and front in which file