Создание интернет-магазинов
на Opencart

Модули, шаблоны и дополнения сделанные нами

Категории 3 уровня в Opencart 2.3

1. В  catalog\controller\common\header.php меняем

foreach ($children as $child) {
$filter_data = array(
'filter_category_id'  => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['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'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child2['category_id']),
);
}
$filter_data = array(
'filter_category_id'  => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'children' => $children_data2,
);
}


2. В шаблоне header.tpl это

<?php foreach ($children as $child) { ?>
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
<?php } ?>


на это

<?php foreach ($children as $child) { ?>
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a>
<?php     if ($child['children']) {?>
<div class="child"><ul class="list-unstyled">
<?php foreach ($child['children'] as $child) { ?>
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
<?php } ?>
</ul></div>
<?php } ?>
</li>
<?php } ?>


3. В файл стилей stylesheet.css добавим

.child {display:none;}
#menu .dropdown-inner ul > li:hover .child {display:block;
background: #000;
/*border: 1px solid #ddd;*/
left: 100%;
position: absolute;
top: 0;
z-index: 9;
}
nav#menu.navbar ul li div.dropdown-menu div ul li {position:relative;}