Получилось - даже 4 уровень категорий))
Вот изменения в контроллере
это
*$this->data['categories'][] = array(
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
'thumb' => $result['image'],
'category_id' => $result['category_id']
);
Заменить на это
$level_1_total = $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $result['category_id']));
$level_2_data = array();
$categories_2 = $this->model_catalog_category->getCategories($result['category_id']);
foreach ($categories_2 as $category_2) {
$data = array(
'filter_category_id' => $category_2['category_id'],
'filter_sub_category' => true
);
$level_2_total = $this->model_catalog_product->getTotalProducts($data);
$level_1_total += $level_2_total;
$level_3_data = array();
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
foreach ($categories_3 as $category_3) {
$data = array(
'filter_category_id' => $category_3['category_id'],
'filter_sub_category' => true
);
$level_3_total = $this->model_catalog_product->getTotalProducts($data);
//$level_2_total += $level_3_total;
$level_3_data[] = array(
'category_id' => $category_3['category_id'],
'name' => $category_3['name'] . ($this->config->get('config_product_count') ? ' (' . $level_3_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $result['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
);
}
$level_2_data[] = array(
'category_id' => $category_2['category_id'],
'name' => $category_2['name'] . ($this->config->get('config_product_count') ? ' (' . $level_2_total . ')' : ''),
'children' => $level_3_data,
'href' => $this->url->link('product/category', 'path=' . $result['category_id'] . '_' . $category_2['category_id'])
);
}
$this->data['categories'][] = array(
'category_id' => $result['category_id'],
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $level_1_total . ')' : ''),
'children' => $level_2_data,
'href' => $this->url->link('product/category', 'path=' . $result['category_id'])
);
В tpl вывод
<?php foreach ($categories as $category_1) { ?>
<li>
<a href="<?php echo $category_1['href']; ?>"><?php echo $category_1['name']; ?></a>
<?php if ($category_1['children']) { ?>
<ul>
<?php foreach ($category_1['children'] as $category_2) { ?>
<li>
<a href="<?php echo $category_2['href']; ?>"><?php echo $category_2['name']; ?></a>
<?php if ($category_2['children']) { ?>
<ul>
<?php foreach ($category_2['children'] as $category_3) { ?>
<li><a href="<?php echo $category_3['href']; ?>"><?php echo $category_3['name']; ?></a></li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>