Post by labeshops » Sat Aug 01, 2020 5:58 am

I finally took the plunge and upgraded to v3 and love a lot of the new multistore features. Still a lot of work to do, but getting there.

One thing I am confused about is the seo urls and couldn't find an answer by googling. While I love that I can make the seo keywords unique by store if I want to, if I only have one set for default and later add that product to one of my other stores, will the other store use the default seo url if I forget to set one for the store? Or will it show up in the 2nd store with the non-seo path product_id etc??

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by letxobnav » Sat Aug 01, 2020 11:17 am

product keywords are defined per product query product_id=xxx, language_id and store_id so you will have to define keywords per product, per language, per store. You could also just try it out.

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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by labeshops » Sat Aug 01, 2020 7:41 pm

So is there a mod that will use the default store's seo url if no others are defined? I did a search in marketplace, but not seeing anything other than autogenerators which I do not want to use.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by letxobnav » Mon Aug 03, 2020 10:32 am

Well, there are two parts to seo urls, translation from seo url keyword to get variable and visa versa.

1) to translate from keywords to get variables it uses:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE keyword = '" . $this->db->escape($part) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
it is not concerned with language, as long as it finds a match it is ok.
Read somewhere long time ago that that was as a failsafe which is nonsense and a mistake in my view.

Still, you could change that to:

Code: Select all

$query = $this->db->query(
"SELECT * 
FROM " . DB_PREFIX . "seo_url 
WHERE keyword = '" . $this->db->escape($part) . "'
AND (store_id = '" . (int)$this->config->get('config_store_id') . "' OR store_id = 0)
ORDER BY store_id DESC"
);
which tries to find it for the current store id or the default store.
So chances are it could find 2 occurrences so we sort them to pick the current store over the default one.

2) to translate get variables to keywords it uses several depending on the route:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
here it does use the language id as it should.
you could use the same principle:

Code: Select all

$query = $this->db->query(
"SELECT * 
FROM " . DB_PREFIX . "seo_url 
WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'
AND (store_id = '" . (int)$this->config->get('config_store_id') . "' OR store_id = 0)
AND language_id = '" . (int)$this->config->get('config_language_id') . "'
ORDER BY store_id DESC"
);
so instead of just finding the keyword for the current store, it finds the keyword for default as well but takes current over default.

you can do the same for the remaining category query.

I have not tested this as I do not have multiple stores but it is a peanut change.

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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by labeshops » Mon Aug 03, 2020 7:39 pm

Okay you kinda lost me in all this. I only use English so ignore the languages stuff if that simplifies it.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA
Who is online

Users browsing this forum: paola_84, paulfeakins and 44 guests