foreach ($categories as $category) {
//Будем вычислять кол-во товаров в категориях только если это кол-во надо показывать
if ($show_product_count) {
$total = $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $category['category_id']));
}
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
//Будем вычислять кол-во товаров в категориях только если это кол-во надо показывать
if ($show_product_count) {
$data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$total += $product_total;
}
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($show_product_count ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ($show_product_count ? ' (' . $total . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}