Hello, I have some issues with the SEO links on my opencart site, specific with my DEFAULT opencart pages like "contact us"
► I have enables SEO from Settings⇾ Server⇾ Use SEO URLs
► I have cleared the Cache
► and I created new entry in Design⇾ SEO URL (e.g. for contact us page) see settings bellow
Query 1
Query⇾ information/contact
Keyword⇾ contact-us
Language⇾ English
Query 2
Query⇾ information/contact
Keyword⇾ επικοινωνία
Language⇾ Greek
So when I click on a link, that suppose to go to contact us, the page has the default URL (MVC style URL) and not the SEO URL that I declared.
When I'm writing the URL my self, like "domain.com/contact-us" the URL works perfectly.
What is happening ? I'm new to opencart, so I don't know what else I can do.
General Information
OC Version: 3.0.3.6
Theme: Journal 3
Note: Multilingual Site (2 Languages)
Thank you in advance,
Olga
► I have enables SEO from Settings⇾ Server⇾ Use SEO URLs
► I have cleared the Cache
► and I created new entry in Design⇾ SEO URL (e.g. for contact us page) see settings bellow
Query 1
Query⇾ information/contact
Keyword⇾ contact-us
Language⇾ English
Query 2
Query⇾ information/contact
Keyword⇾ επικοινωνία
Language⇾ Greek
So when I click on a link, that suppose to go to contact us, the page has the default URL (MVC style URL) and not the SEO URL that I declared.
When I'm writing the URL my self, like "domain.com/contact-us" the URL works perfectly.
What is happening ? I'm new to opencart, so I don't know what else I can do.
General Information
OC Version: 3.0.3.6
Theme: Journal 3
Note: Multilingual Site (2 Languages)
Thank you in advance,
Olga
Default OC can translate seo keywords to a route, it just does not translate a route to a keyword.
In order to do that you need to add code to catalog/controller/startup/seo_url.php
you change this:
to this:
then it also writes the seo url for just routes like information/contact, account/register, etc.
It also removes the index.php?route=common/home from the home page.
In order to do that you need to add code to catalog/controller/startup/seo_url.php
you change this:
Code: Select all
} elseif ($key == 'path') {
$categories = explode('_', $value);
foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
}
Code: Select all
} elseif ($key == 'path') {
$categories = explode('_', $value);
foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
} elseif (!in_array($data['route'],array('common/language/language','common/currency/currency','product/product','product/category','product/manufacturer/info','information/information'))) {
// all other cases for just route settings & eliminating unnecessary queries
if ($key == 'route') {
// no need to query root
if ($value == 'common/home') {
$url = '/';
} else {
$sql = "SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . $this->config->get('config_language_id') . "'";
$query = $this->db->query($sql);
if ($query->num_rows) {
if ($url != '/') $url .= '/';
$url .= $query->row['keyword'];
unset($data[$key]);
}
}
}
}
It also removes the index.php?route=common/home from the home page.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Hello, I tried this on OC 3.0.3.8 with Journal3 and it's not working. Any other fix?letxobnav wrote: ↑Tue Oct 06, 2020 11:28 pmDefault OC can translate seo keywords to a route, it just does not translate a route to a keyword.
In order to do that you need to add code to catalog/controller/startup/seo_url.php
you change this:to this:Code: Select all
} elseif ($key == 'path') { $categories = explode('_', $value); foreach ($categories as $category) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($query->num_rows && $query->row['keyword']) { $url .= '/' . $query->row['keyword']; } else { $url = ''; break; } } unset($data[$key]); }
then it also writes the seo url for just routes like information/contact, account/register, etc.Code: Select all
} elseif ($key == 'path') { $categories = explode('_', $value); foreach ($categories as $category) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($query->num_rows && $query->row['keyword']) { $url .= '/' . $query->row['keyword']; } else { $url = ''; break; } } unset($data[$key]); } elseif (!in_array($data['route'],array('common/language/language','common/currency/currency','product/product','product/category','product/manufacturer/info','information/information'))) { // all other cases for just route settings & eliminating unnecessary queries if ($key == 'route') { // no need to query root if ($value == 'common/home') { $url = '/'; } else { $sql = "SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . $this->config->get('config_language_id') . "'"; $query = $this->db->query($sql); if ($query->num_rows) { if ($url != '/') $url .= '/'; $url .= $query->row['keyword']; unset($data[$key]); } } } }
It also removes the index.php?route=common/home from the home page.
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Who is online
Users browsing this forum: No registered users and 73 guests