Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iledcom/18b298b2505ade388f06 to your computer and use it in GitHub Desktop.
Save iledcom/18b298b2505ade388f06 to your computer and use it in GitHub Desktop.
OpenCart. The third level of the categories in the main menu
//3 level
//*** Получаем список подкгатегорий для каждой категории второго уровня
$subchildren = $this->model_catalog_category->getCategories($child['category_id']);
//*** Обнуляем массив для каждого набора подкатегорий вторго уровня
$subchildren_data = array();
//*** Получаем список подкгатегорий для каждой категории второго уровня
foreach ($subchildren as $subchild) {
//Будем вычислять кол-во товаров в категориях только если это кол-во надо показывать
if ($this->config->get('config_product_count')) {
$data = array(
'filter_category_id' => $subchild['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
}
//*** Получаем список подкгатегорий для каждой категории второго уровня формируем массив со списками подкатегорий второго уровня
$subchildren_data[] = array(
'name' => $subchild['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $subchild['category_id'])
);
}
$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']),
//*** Добавляем к каждой категории первого уровня массив с подкатегориями второго уровня
'subchildren' => $subchildren_data,
);
}
//3 level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment