Php 只有一个子类别的Opencart 2.0.0顶部菜单应转到该页面的缩略图
我需要opencart 2.0的帮助。顶部菜单 如果一个主类别只有一个子类别,那么它应该跳过拼贴页面,直接进入该子类别的大拇指Php 只有一个子类别的Opencart 2.0.0顶部菜单应转到该页面的缩略图,php,opencart,opencart2.x,Php,Opencart,Opencart2.x,我需要opencart 2.0的帮助。顶部菜单 如果一个主类别只有一个子类别,那么它应该跳过拼贴页面,直接进入该子类别的大拇指 我不熟悉PHP和opencart。我已经尝试过更改header controller和model catalog,但这两个更改都不起作用。对于任何想要回答这个问题的人,我必须编辑catalog/controller/common/header.php 和catalog/model/catalog/category.php 在category.php中,我添加了这个函数
我不熟悉PHP和opencart。我已经尝试过更改header controller和model catalog,但这两个更改都不起作用。对于任何想要回答这个问题的人,我必须编辑catalog/controller/common/header.php 和catalog/model/catalog/category.php 在category.php中,我添加了这个函数
public function getCategoryFirstChildId($category_id) {
$query = $this->db->query('SELECT category_id FROM '. DB_PREFIX .'category WHERE parent_id = '. (int)$category_id .' ORDER BY category_id ASC LIMIT 1');
return $query->row['category_id'];
}
在header.php中,我对代码做了如下更改
/* New Code starts here */
/*NEW =>*/ $category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category['category_id']);
/*NEW =>*/ $first_child_id = $this->model_catalog_category->getCategoryFirstChildId($category['category_id']);
if($category_total>1)
{
// 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'])
);
}
else
{
// 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']. '_' . $first_child_id)
);
}
/* New Code ends here */