Post by saliverdim » Fri Nov 24, 2017 10:26 pm

I have 2 product
1-pinpon
2-pınpon
I search pinpon , result 1 :(
I search pınpon , result 1 :(

must result all :(

2.1.0.2 journal

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by straightlight » Fri Nov 24, 2017 10:32 pm

In catalog/model/catalog/product.php file,

replace:

Code: Select all

$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
with:

Code: Select all

$implode[] = "pd.name LIKE TRIM(LCASE('%" . $this->db->escape($word) . "%'))";

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MrPhil » Sat Nov 25, 2017 1:01 am

What's TRIMming '% some term %' going to do? Does TRIM work inside a string, or just leading and trailing blanks (which don't exist here)? Did you mean to trim the search term before wrapping %'s around it?

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by straightlight » Sat Nov 25, 2017 1:08 am

MrPhil wrote:
Sat Nov 25, 2017 1:01 am
What's TRIMming '% some term %' going to do? Does TRIM work inside a string, or just leading and trailing blanks (which don't exist here)? Did you mean to trim the search term before wrapping %'s around it?
Be reminded that both %, one at the beginning and one at the end, are being used on this query which means that anything from the beginning and the end can be matched. Which is why, trim is implicit with this string search.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by saliverdim » Sun Nov 26, 2017 1:46 am

search in categories and result show ?

can you help me ?

thank you

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by straightlight » Sun Nov 26, 2017 1:52 am

Which OC version?

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by saliverdim » Sun Nov 26, 2017 8:20 am

2.1.0.2
thank you thank you :)

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by MrPhil » Thu Nov 30, 2017 3:07 am

Something I didn't notice before: one is a regular "i", and the other is a "dotless i". Is there a reason for the difference? Was it deliberate? Changing the dotless i to a regular ASCII i might solve the problem, if it was accidental. Otherwise, a regular i and a dotless i won't match in a search. If you want to keep the dotless i, take a look at the page and database encoding -- dotless i is in Unicode Latin Extended-A, and not normally found in a Latin-x code page (at least, not Latin-1). It might have snuck in through Windows CP-125x, around x9D or so ("smart quotes"). Still, I don't see how one can expect the search to return both of them.

Possibly, your database can be configured to treat "i" and "dotless i" the same in searches, but I don't know how to do it. It would probably be something in the selected "collation".

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by straightlight » Thu Nov 30, 2017 4:30 am

Let's troubleshoot this issue regarding accentuated characters. In system/helper/utf8.php file, at the bottom of fhe file,

find:

Code: Select all

return $string;
	}
replace with:

Code: Select all

return $string;
	}

function removeAccents($value, $language) {
     $code = explode('-', trim($language));
     
     setlocale(LC_ALL, strtolower($code[0]) . "_" . strtoupper($code[1]) . ".utf8"); 
    
    return iconv('UTF-8', 'ASCII//TRANSLIT',$value);
}
Then, in your catalog/model/catalog/product.php file,

find all instances of:

Code: Select all

$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
replace all with:

Code: Select all

$implode[] = "pd.name LIKE '%" . $this->db->escape(replaceAccents($word, $this->session->data['language'])) . "%'";
Then, find all instances of:

Code: Select all

$sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
replace all with:

Code: Select all

$sql .= " OR pd.description LIKE '%" . $this->db->escape(replaceAccents($data['filter_name'], $this->session->data['language'])) . "%'";
See if that solves the issue.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MrPhil » Sat Dec 02, 2017 3:16 am

If you have any trouble with the iconv() code, be sure to read http://php.net/manual/en/function.iconv.php. The TRANSLIT may not be supported on all PHP installations, but if it is, it is supposed to transliterate characters to the nearest ASCII equivalent (e.g., ö/ö becomes oe). You should test that dotless i becomes a regular i. Since this is server-side, you don't have to worry about what browsers your customers are using, but if you're on a separate database server, that needs to be checked.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by saliverdim » Tue Jan 02, 2018 9:01 am

how to search in sub categories ?

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by straightlight » Tue Jan 02, 2018 9:05 am

saliverdim wrote:
Tue Jan 02, 2018 9:01 am
how to search in sub categories ?
This extension may be useful: https://www.opencart.com/index.php?rout ... n_id=12145

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 7 guests