Site search – transliteration and character replace

Tagged: 

ThemeBurn SupportForumsOpenCart ThemesShoppica 2 OpenCart ThemeCompatible extensionsSite search – transliteration and character replace

Hi, TB, I’m brazilian and in portuguese we write some words with some accent marks, for example: In english Tennis, in portuguese we write Tênis. I’m talking about that character above the letter “e”.

So, I’m selling Tennis in my store and if the customer types “tênis” in the search bar and hits enter, that works perfectly. But, if the person types “tenis”, without the thing above the letter “e”, which is basically our street language, the search system doesn’t find anything. How can we make the search system ignore writting mistakes such that one?

A second question: Is it possible to make the search system search for the shoes numbers without having to add them in the product tags one by one?

Thanks in advance, TB.

September 30, 2012 at 12:42 am #13807

Guys, we found this and worked…

http://www.opencartbrasil.com.br/forum/viewtopic.php?f=40&t=4722&p=28934#p28934

Its in portuguese, but says:

Generate a new xml file, copy the code below and save this xml file in vqmod folder.

<modification>
        <id>Busca indiferente da acentuacao</id>
        <version>1.0</version>
        <vqmver>1.1.0</vqmver>
        <author>Lien Kuan Min</author>
        <file name="catalog/model/catalog/product.php">
                <operation>
                        <search position="after" index="1,2"><![CDATA[$words = explode(' ', trim(preg_replace('/\s\s+/', ' ', $data['filter_name'])));]]></search>
                        <add><![CDATA[
                         $padrao=array("/(a|á|à|ã|â)/" ,"/(e|é|ê)/","/(i|í|î)/","/(o|ó|õ|ô)/","/(u|ú|û|ü)/","/(c|ç)/");
                         $substituicao=array("(a|á|à|ã|â)" ,"(e|é|ê)" ,"(i|í|î)" ,"(o|ó|õ|ô)" ,"(u|ú|û|ü)" ,"(c|ç)" );
                        ]]></add>
                </operation>
                <operation>
                        <search position="replace" index="1,2"><![CDATA[$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(pd.description) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";]]></search>
                        <add><![CDATA[
                        $implode[] = 'LCASE(pd.name) REGEXP "'.preg_replace($padrao, $substituicao, $this->db->escape(utf8_strtolower($word))).'" OR LCASE(pd.description) REGEXP "'.preg_replace($padrao, $substituicao, $this->db->escape(utf8_strtolower($word))) .'"';
                        ]]></add>
                </operation>
                <operation>
                        <search position="replace" index="1,2"><![CDATA[$implode[] = "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'";]]></search>
                        <add><![CDATA[
                         $implode[] = 'LCASE(pd.name) REGEXP "'.preg_replace($padrao, $substituicao, $this->db->escape(utf8_strtolower($word))).'"';
                        ]]></add>
                </operation>
        </file>
        <file name="admin/model/catalog/product.php">
                <operation>
                        <search position="replace" index="1,2"><![CDATA[$sql .= " AND LCASE(pd.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";]]></search>
                        <add><![CDATA[
                         $padrao=array("/(a|á|à|ã|â)/" ,"/(e|é|ê)/","/(i|í|î)/","/(o|ó|õ|ô)/","/(u|ú|û|ü)/","/(c|ç)/");
                         $substituicao=array("(a|á|à|ã|â)" ,"(e|é|ê)" ,"(i|í|î)" ,"(o|ó|õ|ô)" ,"(u|ú|û|ü)" ,"(c|ç)" );
                         $sql .= " AND LCASE(pd.name) REGEXP '" .preg_replace($padrao, $substituicao, $this->db->escape(utf8_strtolower($data['filter_name']))) . "'";
                         ]]></add>
                </operation>
        </file>
</modification>

Thank you anyway.

October 6, 2012 at 9:56 pm #14067

Hi,

Thanks for the vqmod :)

We moved the topic in “Compatible extensions”.

Best,
ThemeBurn team

October 9, 2012 at 2:05 pm #14134
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Compatible extensions’ is closed to new topics and replies.