Нашел модуль который как раз выводит подкатегории!! Проблема только в том, что он выводит только подкатегории первого уровня! Пример: если захожу в родителскую категорию, он показывает подкатегории 1 уровня (тут все норм), если я дальше захожу в подкатегорию 1 уровня, он опять показывает эти же подкатегории, т. е. глубже не лезет (((( подскажите что подправить пожалуйста!!
Сам модуль http://www.opencart.com/index.php?route=extension/extension/info&extension_id=12623&filter_search=category%20sidebar&filter_download_id=31&sort=e.price&order=ASC&page=4
subcategory.php
<?php
class ControllerModuleSubCategory extends Controller {
private $_name = "subcategory";
private $_version = "0.2";
protected function index($setting) {
$this->language->load('module/subcategory');
$this->data['heading_title'] = $this->language->get('heading_title');
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}
if (isset($parts[0])) {
$this->data['category_id'] = $parts[0];
} else {
$this->data['category_id'] = 0;
}
if (isset($parts[1])) {
$this->data['child_id'] = $parts[1];
} else {
$this->data['child_id'] = 0;
}
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$total = $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $category['category_id']));
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$total += $product_total;
$children_data[] = array(
'category_id' => $child['category_id'],
//'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'name' => $child['name'] ,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
//'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
'name' => $category['name'] ,
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
$this->data['subcategories'] = $this->data['categories'];
foreach ($this->data['categories'] as $id => $cat) {
if ($cat['category_id']==$this->data['category_id']) {
if ($this->config->get($this->_name . '_catname')): $this->data['heading_title'] = $cat['name']; endif;
$this->data['subcategories'] = $cat['children'];
}
}
if (count($this->data['subcategories'])<1) { $this->data['subcategories'] = $this->data['categories']; }
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/subcategory.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/subcategory.tpl';
} else {
$this->template = 'default/template/module/subcategory.tpl';
}
$this->render();
}
}
?>
subcategory.tpl
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<ul class="box-category">
<?php foreach ($subcategories as $num => $category) { ?>
<li>
<?php if ($category['category_id'] == $category_id || $category['category_id'] == $child_id) { ?>
<a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>
<?php /*if ($category['children']) { ?>
<ul>
<?php foreach ($category['children'] as $child) { ?>
<li>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="active"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>"> - <?php echo $child['name']; ?></a>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php }*/ ?>
</li>
<?php } ?>
</ul>
</div>
</div>