Код в контроллере будет выглядеть ПРИМЕРНО так:
foreach ($categories as $category)
{
if ($category['top'])
{
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child)
{
// Level 3
$children_data2 = array();
$children2 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children2 as $child2)
{
// Level 4
$children_data3 = array();
$children3 = $this->model_catalog_category->getCategories($child2['category_id']);
foreach ($children3 as $child3)
{
$children_data3[] = array('name' => $child3['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child3['category_id']));
}
$children_data2[] = array('name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child2['category_id']),
'children' => $children_data3);
}
$children_data[] = array('name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'children' => $children_data2);
}
// Level 1
$this->data['categories'][] = array('name' => $category['name'],
'children' => $children_data,
'active' => in_array($category['category_id'], $parts),
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id']));
}
}