I’ve recently rebuilt my OC3.X site in OC4.0.1.1.
I’ve had my site running for years and it’s well indexed with many pages, and have more sites to move over from 3 to 4.
Everything has gone fine except for the language in the URL. I’ve searched on here and searched on Google but to no avail.
Example:
https://www.domain.com/en-gb/product/ca ... roduct-url
This is a single language site.
Adding the en-gb means my urls change which is a logistical nightmare for historical marketing.
Am I missing something really obvious in the admin, or is adding the language to the url really a core feature of OC4?
It's a core feature, unfortunately. I agree that it makes no sense for a single language site, but I haven't had time to look into it at this point.
I just went through the code and I'm not entirely sure this will work, but try the following and see how it goes:
------------------------------------------------------------------------------
IN:
/system/library/url.php
BEFORE:
foreach ($this->rewrite as $rewrite) {
WITH:
$url = str_replace('language=en-gb', '', $url);
$url = str_replace('&&', '&', $url);
------------------------------------------------------------------------------
That's the simplest edit I could come up with, but if it doesn't work let me know and I'll see if I can find an alternate method.
I just went through the code and I'm not entirely sure this will work, but try the following and see how it goes:
------------------------------------------------------------------------------
IN:
/system/library/url.php
BEFORE:
foreach ($this->rewrite as $rewrite) {
WITH:
$url = str_replace('language=en-gb', '', $url);
$url = str_replace('&&', '&', $url);
------------------------------------------------------------------------------
That's the simplest edit I could come up with, but if it doesn't work let me know and I'll see if I can find an alternate method.
Johnathan, thanks for taking the time to reply.
I read a thread on Git after I posted this where Daniel confirmed it's a core feature.
It makes upgrading to 4 off-putting, and even new single-lang sites shouldn't have this URL structure.
Your suggestion does strip the en-gb from the URL, and both versions load correctly. The canonical still displays en-gb, so there's a few places to look at.
We'll spend more time on this later in the week and I'll post the results in here, as I can see a few people have asked the question on various sites.
Thanks again.
I read a thread on Git after I posted this where Daniel confirmed it's a core feature.
It makes upgrading to 4 off-putting, and even new single-lang sites shouldn't have this URL structure.
Your suggestion does strip the en-gb from the URL, and both versions load correctly. The canonical still displays en-gb, so there's a few places to look at.
We'll spend more time on this later in the week and I'll post the results in here, as I can see a few people have asked the question on various sites.
Thanks again.
Personally, I feel like v4 needs more time in the kitchen before using it on a production site. Why did you want to move from 3 to 4?
I'm trying to apply your fix for the /en-gb issue in 4.0.1.1 but it doesn't seem to be working for me. I'm suspecting I'm not reading your instructions properly.
I'm editing url.php as instructed and putting the 2 new lines before the foreach command but it throws up a ton of errors, all saying:
Warning: Undefined array key 1 in /home/yourwebsite/public_html/catalog/controller/startup/seo_url.php on line 61
I'm editing url.php as instructed and putting the 2 new lines before the foreach command but it throws up a ton of errors, all saying:
Warning: Undefined array key 1 in /home/yourwebsite/public_html/catalog/controller/startup/seo_url.php on line 61
Code: Select all
public function link(string $route, string|array $args = '', bool $js = false): string {
$url = $this->url . 'index.php?route=' . $route;
if ($args) {
if (is_array($args)) {
$url .= '&' . http_build_query($args);
} else {
$url .= '&' . trim($args, '&');
}
}
// the two new lines here, before the foreach, the second line is line 61
$url = str_replace('language=en-gb', '', $url);
$url = str_replace('&&', '&', $url);
foreach ($this->rewrite as $rewrite) {
$url = $rewrite->rewrite($url);
}
if (!$js) {
return str_replace('&', '&', $url);
} else {
return $url;
}
}
well i tried and i have the same error showing, the million dollar question is does this fix works ok even with the error ? i can always hide this error , but will affect the operation of the urls and seo negative ? or once its done it stays like this. Also in a feature upgrade i guess i have to re insert this code to hide the UGLY language code showing in my urls ??
well that was fast, i found the solutions as described here, for me worked 100% !
https://webocreation.com/how-to-remove- ... #gsc.tab=0
https://webocreation.com/how-to-remove- ... #gsc.tab=0
Just for completeness, there was also an entry at Github (but finally refused):
https://github.com/opencart/opencart/pu ... be97d19870
https://github.com/opencart/opencart/pu ... be97d19870
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Who is online
Users browsing this forum: No registered users and 4 guests