[Solved] Third level menu counter
Posted: Fri Jul 29, 2016 9:47 pm
Hello people,
Need to show number of product in category in third level menu.
This is code
Issue is here I suppose (...not sure)
But don`t know what is wrong.
Thanks for help!
Need to show number of product in category in third level menu.
This is code
Code: Select all
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
// Level 3
$children_data2 = array();
$children2 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children2 as $child2) {
$children_data2[] = array(
'name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), //new
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'].'_'.$child2['category_id'])
);
}
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'children'=>$children_data2,
'name' => $child['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}
Code: Select all
'name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), //new
Thanks for help!