что это за дичь
$data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
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) {
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
// Level 3
$children_level2 = $this->model_catalog_category->getCategories($child['category_id']);
$children_data_level2 = array();
foreach ($children_level2 as $child_level2) {
$data_level2 = array(
'filter_category_id' => $child_level2['category_id'],
'filter_sub_category' => true
);
$product_total_level2 = '';
if ($this->config->get('config_product_count')) {
$product_total_level2 = ' (' . $this->model_catalog_product->getTotalProducts($data_level2) . ')';
}
$children_data_level2[] = array(
'name' => $child_level2['name'],
'href' => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child_level2['category_id']),
'id' => $category['category_id']. '_' . $child['category_id']. '_' . $child_level2['category_id']
);
}
$children_data[] = array(
'name' => $child['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'id' => $category['category_id']. '_' . $child['category_id'],
'children_level2' => $children_data_level2,
);
}
// 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'])
);
}
}
а для вывода в сайдбаре...
<div class="megamenu-wrapper">
<div class="megamenu-pattern">
<div class="container">
<ul class="megamenu shift-up">
<?php foreach ($categories as $category) { ?>
<?php if ($category['children']) { ?>
<li class="with-sub-menu hover"><p class="close-menu"></p><p class="open-menu"></p>
<a href="<?php echo $category['href'];?>"><span><strong><?php echo $category['name']; ?></strong></span></a>
<?php } else { ?>
<li>
<a href="<?php echo $category['href']; ?>"><span><strong><?php echo $category['name']; ?></strong></span></a>
<?php } ?>
<?php if ($category['children']) { ?>
<?php
$width = '100%';
$row_fluid = 3;
if($category['column'] == 1) { $width = '220px'; $row_fluid = 12; }
if($category['column'] == 2) { $width = '500px'; $row_fluid = 6; }
if($category['column'] == 3) { $width = '700px'; $row_fluid = 4; }
?>
<div class="sub-menu" style="width: <?php echo $width; ?>">
<div class="content">
<p class="arrow"></p>
<div class="row hover-menu">
<?php for ($i = 0; $i < count($category['children']);) { ?>
<div class="col-sm-<?php echo $row_fluid; ?> mobile-enabled">
<div class="menu">
<ul>
<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($category['children'][$i])) { ?>
<li>
<?php if(count($category['children'][$i]['children_level2'])>0){ ?>
<a href="<?php echo $category['children'][$i]['href']; ?>" class="activSub"><?php echo $category['children'][$i]['name'];?></a>
<?php } else { ?>
<a href="<?php echo $category['children'][$i]['href']; ?>" class="main-menu"><?php echo $category['children'][$i]['name']; ?></a>
<?php } ?>
<?php if ($category['children'][$i]['children_level2']>0) { ?>
<ul>
<?php for ($wi = 0; $wi < count($category['children'][$i]['children_level2']); $wi++) { ?>
<li><a href="<?php echo $category['children'][$i]['children_level2'][$wi]['href']; ?>" ><?php echo $category['children'][$i]['children_level2'][$wi]['name']; ?></a></li>
<?php } ?>
</ul>
<?php /*?></div><?php */?>
<?php } ?>
</li>
<?php } ?>
<?php } ?>
</ul>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
<?php if($theme_options->get( 'megamenu_type' ) == 4 || $theme_options->get( 'megamenu_type' ) == 5 || $theme_options->get( 'megamenu_type' ) == 6 || $theme_options->get( 'megamenu_type' ) == 9 || $theme_options->get( 'megamenu_type' ) == 14 || $theme_options->get( 'megamenu_type' ) == 19 || $theme_options->get( 'megamenu_type' ) == 29) { ?>
</div>
<?php } ?>
только для сабменю стили настройте - класс "activSub"