Вывод в категории - подкатегорий, вплоть до 3го уровня с изображением родителя
catalog/controller/product/category.php
$data['categories'] = array();
$results = $this->model_catalog_category->getCategories($category_id);
foreach ($results as $result) {
$children_data = array();
$children = $this->model_catalog_category->getCategories($category_id);
foreach ($children as $child) {
$children_data2 = array();
$children2 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children2 as $child2) {
$children_data2[] = array(
'name' => $child2['name'],
'href' => $this->url->link('product/category', 'path=' . $result['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'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $result['category_id'] . '_' . $child['category_id'])
);
}
$filter_data = array(
'filter_category_id' => $result['category_id'],
'filter_sub_category' => true
);
if ($result['image']) {
$caimage = $this->model_tool_image->resize($result['image'], 100, 100);
}
else {
$caimage = $caimage = $this->model_tool_image->resize('no_image.png', 100, 100);
}
$data['categories'][] = array(
'children' => $children_data,
'column' => $result['column'] ? $result['column'] : 1,
'image' => $caimage,
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}
category.tpl
<div class="row cat_with_img">
<div class="col-sm-12">
<?php foreach ($categories as $category) { ?>
<div class="col-md-4">
<?php if ($category['image']) { ?>
<div class="image">
<a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['image']; ?>" alt="<?php echo $category['name']; ?>" /></a>
</div>
<?php } ?>
<a href="<?php echo $category['href']; ?>"><strong><?php echo $category['name']; ?></strong></a>
<?php if ($category['children']) { ?>
<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) {
?>
<ul class="list-unstyled">
<?php foreach ($children as $child) { ?>
<?php foreach($child['children'] as $child2) {
if ($child['name'] == $category['name']) {
?>
<ul>
<li><a href="<?php echo $child2['href']; ?>"><?php echo $child2['name']; ?></a></li>
</ul>
<?php } } } ?>
</ul>
<?php } ?>
<?php } ?>
</div>
На версии 2.1.0.1 работает 100%.
Кто сделает более изящно - будем рады )))