I know this is a late answer, but this is a deep rooted problem with OpenCarts architecture.
Personally I am not a fan of vQmod, so here is a (what some would call a hack) solution to the problem without using one.
I have seen many alterations to catalog/controller/common/seo_url.php
that add custom seo urls. This fix is compatible with such modifications.
I would also like to add that is by no means the most sophisticated solution in the world but it will guarantee that sub categories with duplicate seo url entries will work as they should.
Find in catalog/controller/common/seo_url.php
if ($url[0] == 'category_id') {
if (!isset($this->request->get['path'])) {
$this->request->get['path'] = $url[1];
} else {
$this->request->get['path'] .= '_' . $url[1];
}
}
Replace with the following
if ($url[0] == 'category_id') {
$categories[$i] = $this->model_catalog_category->getCategory($url[1]);
if (!isset($this->request->get['path'])) {
$this->request->get['path'] = $categories[$i]['category_id'];
} else {
foreach ($query->rows as $row) {
$url = explode('=', $row['query']);
$category_id = $url[1];
$category = $this->model_catalog_category->getCategory($category_id);
if ($category['parent_id'] == $categories[$i - 1]['category_id']) {
$this->request->get['path'] .= '_' . $category['category_id'];
}
}
}
}
Add the following line to the top of the method index()
$this->load->model('catalog/category');
Find the line...
foreach ($parts as $part) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
And replace with the following
$categories = array();
for ($i = 0; $i < count($parts); $i++) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($parts[$i]) . "'");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…