OpenCart Category 侧栏显示可展开的二级分类
其实原模块有的,只是在主分类下才会展开
foreach ($categories as $category) {
$children_data = array();
// if ($category[‘category_id’] == $data[‘category_id’]) { 去掉这个条件
$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
);
$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=’ . $category[‘category_id’] . ‘_’ . $child[‘category_id’])
);
}
//去掉这个条件 }