Answer the question
In order to leave comments, you need to log in
How to display child categories + image, as well as subcategories?
Good evening! Tell me the module or the possibility of implementing the following:
In the catalog of categories (no matter what level), you need to display:
- Category picture
- Category name
- Subcategories
An example of how I want to do it can be found here www.technomarin.ru/index.php?route= product/categor...
I say right away, I just started working with the operating card)
Answer the question
In order to leave comments, you need to log in
In 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($result['category_id']);
foreach($children as $child) {
$filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);
$children_data[] = array(
'category_id' => $child['category_id'],
'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
);
$data['categories'][] = array(
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}
{% if category.children %}
{% for child in category.children %}
<li">
<div >
<a href="{{ child.href }}">{{ child.name }}</a>
</div>
</li>
{% endfor %}
{% endif %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question