Page 1 of 1

Seo url is not found

Posted: Thu Oct 17, 2019 5:46 pm
by pm-netti
This start strange problem with SEO url, OC 3.0.3.2

SEO url: hornby-r8788-skaledale-rural-corrugated-nissen-hut-pre-built
language id: 1

These found from table 'seo_url', also language id is enabled in table 'language'.

My test it work, when 'missing' error status in file startup/seo_url.php:

Code: Select all

 /* else {
		$this->request->get['route'] = 'error/not_found';

		break;
}*/
But other server it is not work. What is this error? Can it is some character collate issue?

Re: Seo url is not found

Posted: Thu Oct 17, 2019 6:02 pm
by letxobnav
In Default OC funding the keyword is language independent, It will take the first occurrence it finds, regardless of language.
Collate error hardly, that mostly happens when you have fields with different collation and try to compare them, besides, Mysql will report such an error.

if your question is, why does this query

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') . "'");
not find

Code: Select all

hornby-r8788-skaledale-rural-corrugated-nissen-hut-pre-built
I would suggest to run the query yourself via phpmyadmin and see.

Re: Seo url is not found

Posted: Thu Oct 17, 2019 6:24 pm
by pm-netti
letxobnav wrote:
Thu Oct 17, 2019 6:02 pm
I would suggest to run the query yourself via phpmyadmin and see.
This is already checked, I am uploaded backup from table 'seo-url', there is not problem.

But new finding:

What mean 'cardinality' of table seo_url? Columns 'query' and 'keyword' cardinality is empty of my test store. But my live store column 'query' cardinality is 59 and column 'keyword' cardinality is 177.
What this cardinality do?

Re: Seo url is not found

Posted: Thu Oct 17, 2019 6:43 pm
by letxobnav
cardinality means how many unique values are there for the column.

Re: Seo url is not found

Posted: Thu Oct 17, 2019 6:53 pm
by pm-netti
letxobnav wrote:
Thu Oct 17, 2019 6:43 pm
cardinality means how many unique values are there for the column.
These Cardnality is not can change in phpmyadmin. Can these do issue?

I think, that this is Opencart bug. My test in file startup/seo_url.php:

Code: Select all

$parts = explode('/', $this->request->get['_route_']);
			
			echo "<pre>"; print_r($parts); echo "</pre>";
This create array:

Code: Select all

Array
(
    [0] => peku
    [1] => test
    [2] => peco-sl-310-nickel-silver-rail-joiners-24
)
There array is my admin username and sub domain name. Why?
This remove fisrt key ('peku'):

Code: Select all

	array_pop($parts);
This is not found SEO keyword 'test':

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') . "'");
And stop loop.
This is work my test server:

Code: Select all

 /* else {
					$this->request->get['route'] = 'error/not_found';

					break;
} */
But when it move to other server, it is not work.

I now try use function array_reverse.

Re: Seo url is not found

Posted: Thu Oct 17, 2019 7:11 pm
by letxobnav
cardinality is a measurement not a parameter so no, you cannot set it and if you think you should then you still do not understand what it is.
So what is the issue you are trying to solve now?

[Solved ?]Re: Seo url is not found

Posted: Thu Oct 17, 2019 7:38 pm
by pm-netti
I am solved this? ;D
This is not need anyone foreach loop, this is work my test store:

Code: Select all

$parts = explode('/', $this->request->get['_route_']);
			
$parts = array_reverse($parts);
			
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE keyword = '" . $this->db->escape($parts[0]) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

if ($query->num_rows) {
	
	/*
	
	 do links this 
	 
	 */
	
}  else {
		$this->request->get['route'] = 'error/not_found';
}
Is this OK? ;)

Re: Seo url is not found

Posted: Thu Oct 17, 2019 7:46 pm
by letxobnav
if you do not want the username and test domain to be part of the seo url, make sure your rewritebase in htaccess is correct.

array_reverse has nothing to do with it.

Re: Seo url is not found

Posted: Thu Oct 17, 2019 7:55 pm
by pm-netti
letxobnav wrote:
Thu Oct 17, 2019 7:46 pm
if you do not want the username and test domain to be part of the seo url, make sure your rewritebase in htaccess is correct.
This is not need do, seo url create in admin product page, is not .htaccess.
I added yet this:

Code: Select all

  if(count($parts) > 1){
     $parts = array_reverse($parts);
  }

Re: Seo url is not found

Posted: Thu Oct 17, 2019 8:09 pm
by letxobnav
ok,
the seo url code takes the _route_ get variable and divides it into the chunks between the "/" separator characters.
for each of those chunks as keywords it tries to find a query like product_id=34 or category_id=22...
If it can find those it will use those as the internal get variables you did not have in the seo url.

This has nothing to do with language or the order of the arrays.

But, for the last time, if your rewritebase is not set correctly for the subdirectory your shop is in, then the directory names will become part of the "_route_" get variable and you most likely do not have a matching query for those in the seo_url database and as such you will get a not found page.

Re: Seo url is not found

Posted: Thu Oct 17, 2019 8:47 pm
by pm-netti
letxobnav wrote:
Thu Oct 17, 2019 8:09 pm
This has nothing to do with language or the order of the arrays.
Sort order of array: However, it seems to me that the seo_url address to search for is always the last key one in the array. In this case, array_reverse "does the job to home". :)