Page 1 of 2

in search letter "ı" and "i" problem

Posted: Fri Nov 24, 2017 10:26 pm
by saliverdim
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

Re: in search letter "ı" and "i" problem

Posted: Fri Nov 24, 2017 10:32 pm
by straightlight
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) . "%'))";

Re: in search letter "ı" and "i" problem

Posted: Sat Nov 25, 2017 1:01 am
by MrPhil
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?

Re: in search letter "ı" and "i" problem

Posted: Sat Nov 25, 2017 1:08 am
by straightlight
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.

Re: in search letter "ı" and "i" problem

Posted: Sun Nov 26, 2017 1:46 am
by saliverdim
search in categories and result show ?

can you help me ?

thank you

Re: in search letter "ı" and "i" problem

Posted: Sun Nov 26, 2017 1:52 am
by straightlight
Which OC version?

Re: in search letter "ı" and "i" problem

Posted: Sun Nov 26, 2017 8:20 am
by saliverdim
2.1.0.2
thank you thank you :)

Re: in search letter "ı" and "i" problem

Posted: Thu Nov 30, 2017 3:07 am
by MrPhil
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".

Re: in search letter "ı" and "i" problem

Posted: Thu Nov 30, 2017 4:30 am
by straightlight
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.

Re: in search letter "ı" and "i" problem

Posted: Sat Dec 02, 2017 3:16 am
by MrPhil
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.

Re: in search letter "ı" and "i" problem

Posted: Tue Jan 02, 2018 9:01 am
by saliverdim
how to search in sub categories ?

Re: in search letter "ı" and "i" problem

Posted: Tue Jan 02, 2018 9:05 am
by straightlight
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

Re: in search letter "ı" and "i" problem

Posted: Tue Aug 14, 2018 12:13 am
by saliverdim
please help me ?

search : pınar aylin found.
search : pinar aylin not found :/

serch : hakkı found
search : hakki not found

can you help me ?

2.0.1.2
jorunal

Re: in search letter "ı" and "i" problem

Posted: Tue Aug 14, 2018 1:51 am
by saliverdim
straightlight wrote:
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.
thank you but, 1.steps after website not working :((

and very very hard.

another fix ?

ı use ısearchcortable but same problem :((

ı try 2 years

2.0.1.2

Re: in search letter "ı" and "i" problem

Posted: Tue Aug 14, 2018 9:44 pm
by Johnathan
This is probably a database encoding issue, not an OpenCart code issue. Make sure your database is set to have a collation of "utf8_unicode_ci", so that it works with non-English characters, and can see them as the equivalent English character when entered. If it's not, here's the database query you'd run to change that collation:

Code: Select all

ALTER TABLE oc_product_description CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Make sure you replace "oc_" with your database prefix.

Re: in search letter "ı" and "i" problem

Posted: Thu Aug 16, 2018 4:21 am
by saliverdim
Johnathan wrote:
Tue Aug 14, 2018 9:44 pm
This is probably a database encoding issue, not an OpenCart code issue. Make sure your database is set to have a collation of "utf8_unicode_ci", so that it works with non-English characters, and can see them as the equivalent English character when entered. If it's not, here's the database query you'd run to change that collation:

Code: Select all

ALTER TABLE oc_product_description CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Make sure you replace "oc_" with your database prefix.
hi again,
ı use utf8 general_ci
I tried convert your code but now he does not find anything. :((

Re: in search letter "ı" and "i" problem

Posted: Thu Aug 16, 2018 5:22 am
by Johnathan
If utf8_unicode_ci doesn't work, then switch back to utf8_general_ci. However, the database encoding is still likely the issue, so you should look into that, or hire someone with more experience to look into it for you. You may have other database encoding issues going on, which could be causing conflicts.

Re: in search letter "ı" and "i" problem

Posted: Thu Aug 16, 2018 5:26 am
by saliverdim
Johnathan wrote:
Thu Aug 16, 2018 5:22 am
If utf8_unicode_ci doesn't work, then switch back to utf8_general_ci. However, the database encoding is still likely the issue, so you should look into that, or hire someone with more experience to look into it for you. You may have other database encoding issues going on, which could be causing conflicts.
thank you but I think the problem is in OpenCart itself.because i looked with isenslab isearchcortable extentions and ı tryed ı = i and worked.but this does not work for me.because this time i can not find the letters "i" :/

Re: in search letter "ı" and "i" problem

Posted: Thu Aug 16, 2018 6:21 am
by straightlight
Updated instructions from my previous post.

Replace:

Code: Select all

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

Code: Select all

$implode[] = "pd.name LIKE TRIM(LCASE('%" . $this->db->escape($word) . "%')) COLLATE utf8_general_ci";
to search LONGBLOB field types. Looks for case sensitive but not accent sensitive: https://stackoverflow.com/questions/500 ... h-in-mysql

Re: in search letter "ı" and "i" problem

Posted: Thu Aug 16, 2018 9:56 am
by saliverdim
straightlight wrote:
Thu Aug 16, 2018 6:21 am
Updated instructions from my previous post.

Replace:

Code: Select all

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

Code: Select all

$implode[] = "pd.name LIKE TRIM(LCASE('%" . $this->db->escape($word) . "%')) COLLATE utf8_general_ci";
to search LONGBLOB field types. Looks for case sensitive but not accent sensitive: https://stackoverflow.com/questions/500 ... h-in-mysql
thank you but, 1.steps after website not working :(( first for you message.. :(
and after ı tryed only here your message but problem not resolve :(

catalog/model/catalog/product file : https://we.tl/Kz2PNHcCMq
catalog/model/catalog/isearch file : https://we.tl/Kz2PNHcCMq


I need :
i = ı and ı = i
and
lower case sameone in search.
please :((