Post by opensource » Thu Dec 12, 2024 6:55 am

I wasn't able to find out how OpenCart merges products with seo links on front-end. Could not find anything like LEFT JOIN seo_url table or anything. How this happens? Some cache maybe?

OpenCart v3.0.4.0

Newbie

Posts

Joined
Wed Dec 23, 2020 5:44 am

Post by nonnedelectari » Thu Dec 12, 2024 8:45 am

opensource wrote:
Thu Dec 12, 2024 6:55 am
I wasn't able to find out how OpenCart merges products with seo links on front-end. Could not find anything like LEFT JOIN seo_url table or anything. How this happens? Some cache maybe?

OpenCart v3.0.4.0
Not sure what "merges products with seo links" means.
OC translates incoming seo urls by matching the individual keywords in the seo url (divided by /) to the original querystring parameter.
(Like nice-product to product_id=453, etc).
While creating the seo urls it does the reverse (for every seo url you have on your page).
so it basically does a query per keyword and per querystring parameter to translate to and from an seo url.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by opensource » Thu Dec 12, 2024 3:21 pm

I want to know which function does this on front-end. I don't see any function that would combine basic product data with seo_url table data.

Newbie

Posts

Joined
Wed Dec 23, 2020 5:44 am

Post by by mona » Thu Dec 12, 2024 5:03 pm

In the startup

Code: Select all

public function rewrite($link) {
		$url_info = parse_url(str_replace('&', '&', $link));

		$url = '';

		$data = array();

		parse_str($url_info['query'], $data);

		foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
					$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') . "'");

...
...
		} else {
			return $link;
		}
	}

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


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by paulfeakins » Fri Dec 13, 2024 8:24 pm

Code: Select all

controller/startup/seo_url.php

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: lockiedownunder and 15 guests