<?php
class ControllerExtensionModuleCategory extends Controller
{
public function index()
{
$this->load->language('common/menu');
/*Menu*/
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$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->getChildCategories($category['category_id']);
foreach($children[0] as $child)
{
$filter_data=array(
'filter_category_id'=>$child['category_id'],
'filter_sub_category'=>true);
if(!file_exists(DIR_IMAGE.'catalog/'.$child['image']))$image='image/catalog/3-100x100-60x50.jpg';
else
$image='image/catalog/'.$child['image'];
$children_child = null;
if($children[1]) {
$children_child = $this->getChildInChild($children[1],$category['category_id'].'_'.$child['category_id'],$child['category_id']);
}
$children_data[]=array(
'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']),
'children_child'=>$children_child,
'image'=>$image);
}
/*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']));
}
}
return $this->load->view('extension/module/category', $data);
}
protected function getChildInChild($array,$href,$parent){
/*Level 3*/
$children_data = array();
foreach($array as $child)
{
if($child['parent_id']!=$parent)
continue;
$children_data[]=array(
'name'=>$child['name'],
'href'=>$this->url->link('product/category', 'path='.$href.'_'.$child['category_id']));
}
return $children_data;
}
}
Попробуй это контроллер