Вот кусочек кода, с моей добавкой из sitemap.php, может кто подскажет как его доделать чтобы выводил развернутый список категорий и вложенных подкатегороий или скажите сколько будет стоить
Ниже отрывок кода из файла category.php из МОЯ_ТЕМА/template/product/category.tpl
$results = $this->model_catalog_category->getCategories($category_id);
foreach ($results as $result) {
$filter_data = array(
'filter_category_id' => $result['category_id'],
'filter_sub_category' => true
);
$data['categories'][] = array(
'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)
);
////////////////////////////////////Начало кода взятього из sitemap.php//////////////////////////////////////////
$data['categories'] = array();
$categories_1 = $this->model_catalog_category->getCategories($category_id);
foreach ($categories_1 as $category_1) {
$level_2_data = array();
$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
foreach ($categories_2 as $category_2) {
$level_3_data = array();
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
foreach ($categories_3 as $category_3) {
$level_3_data[] = array(
'name' => $category_3['name'],
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
);
}
$level_2_data[] = array(
'name' => $category_2['name'],
'children' => $level_3_data,
'href' => $this->url->link('product/category', 'path='. $this->request->get['path'] . '_' . $category_1['category_id'] . '_' . $category_2['category_id'])
);
}
$data['categories'][] = array(
'name' => $category_1['name'],
'children' => $level_2_data,
'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'])
);
}
///////////////////////////////////////////////Конец кода взятього из sitemap.php///////////////////////////////////////////////
}
Ниже отрывок кода из category.tpl с вставкой кода из sitemap.tpl, выводящего категории
<?php if ($categories) { ?>
<h3><?php echo $text_refine; ?></h3>
<?php if (count($categories) <= 5) { ?>
<div class="row">
<div class="col-sm-3">
<ul>
<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
<?php } ?>
</ul>
</div>
</div>
<?php } else { ?>
<div class="row">
<?php foreach (array_chunk($categories, ceil(count($categories) / 4)) as $categories) { ?>
<div class="col-sm-3">
<!-- <ul>-->
<!-- <?php foreach ($categories as $category) { ?>-->
<!-- <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>-->
<!-- /////////////////////////////////Код ниже добавил я///////////////////////////////////////////////-->
<ul>
<?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 } ?>
</ul>
<!-- /////////////////////////////////Конец моего кода///////////////////////////////////////////////-->
<!-- <?php } ?>-->
<!-- </ul>
</div>
<?php } ?>
</div>