Opencart Version 2.3.0.2
download_category_id=2 testdownload
download_category_id=178 manuals
In this case category with id 2 is sub category of 178.
Edited startup/seo_url.php [ copy category code and modified ]
public function index() {
Code: Select all
if ($url[0] == 'category_id') {
if (!isset($this->request->get['path'])) {
$this->request->get['path'] = $url[1];
} else {
$this->request->get['path'] .= '_' . $url[1];
}
}
if ($url[0] == 'download_category_id') {
if (!isset($this->request->get['dpath'])) {
$this->request->get['dpath'] = $url[1];
} else {
$this->request->get['dpath'] .= '_' . $url[1];
}
}
Code: Select all
if (!isset($this->request->get['route'])) {
if (isset($this->request->get['product_id'])) {
$this->request->get['route'] = 'product/product';
} elseif (isset($this->request->get['path'])) {
$this->request->get['route'] = 'product/category';
} elseif (isset($this->request->get['manufacturer_id'])) {
$this->request->get['route'] = 'product/manufacturer/info';
} elseif (isset($this->request->get['information_id'])) {
$this->request->get['route'] = 'information/information';
}elseif (isset($this->request->get['dpath'])) {
$this->request->get['route'] = 'download/download_category';
}
}
Code: Select all
elseif ($key == 'path') {
$categories = explode('_', $value);
foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
}elseif ($key == 'dpath') {
$categories = explode('_', $value);
foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'download_category_id=" . (int)$category . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
}
This builds my seo url but i get page not found.
Url : www.mydomain.com/manuals/testdownloads
This url is correct, but page is not found. So i did print on url_info array in rewrite function.
For categories i get
Code: Select all
Array
(
[scheme] => https
[host] => www.mydomain.com
[path] => /index.php
[query] => route=product/category&path=76
)
Code: Select all
Array
(
[scheme] => https
[host] => www.mydomain.com
[path] => /index.php
[query] => route=download_category_id=2&dpath=178_2
)
What i am missing or doing wrong, any help would be appreciated.
Thanks