Forums / Addon Language Packs / UTF8 problems with Advanced Search

UTF8 problems with Advanced Search

Locked

Started by saskvo4 on 30 Aug 2007, 4:33 PM · Views: 6,139

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
30 Aug 2007, 4:33 PM
#1
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

UTF8 problems with Advanced Search

I am using UTF8 encoding for my English/Bulgarian zen-cart.The problem is that when I insert Cyrillic text in the keywords field in Advanced Search i always get "There is no product that matches the search criteria."If I use Latin keywords everything works fine.In my database all the products names and descriptions are written in the correct Cyrillic and Latin characters.
Any help on this issue would be much appreciated!

1 Sep 2007, 3:48 PM
#2
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

In \includes\functions\functions_general.php i removed the STRTOLOWER() part by changing

 
function zen_parse_search_string($search_str = '', &$objects) {
$search_str = trim(strtolower($search_str));
 

to

 function zen_parse_search_string($search_str = '', &$objects) {
$search_str = trim($search_str);
 

and it seems to be working fine with both Cyrillic and English chars but i guess it may lead to some other kind of problems with the search modlue.Any suggestions of a better solution to this issue are welcome.

2 Sep 2007, 8:29 AM
#3
ronson avatar

ronson

New Zenner

Join Date:
Oct 2006
Posts:
20
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Hi, I also run Englsih/Bulgarian ZenCart on UTF-8 and even with that tweak the search does not work for cyrillic characters. You say you only have problems with the advanced search, I have problems with the advanced search as well as with the simple search sidebox. Any one can help, please?

2 Sep 2007, 11:29 AM
#4
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Simple search directs you to advanced search so i refer as advanced search to both of them:)

If you use utf8 for your English/Bulgarian zen-cart you should do some other changes before everything works correct.

2 Sep 2007, 11:48 AM
#5
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

1.All of your mysql tables must use utf8 charset and be in utf8_general_ci collation

2.Your language files (English.php Bulgarian.php) must contain :

define('CHARSET', 'utf-8');

3.your /includes/classes/db/mysql/query_factory.php about line 37 must be changed from

function connect($zf_host, $zf_user, $zf_password, $zf_database, $zf_pconnect = 'false', $zp_real = false) {
//@TODO error class required to virtualise & centralise all error reporting/logging/debugging
    $this->database = $zf_database;
    if (!function_exists('mysql_connect')) die ('Call to undefined function: mysql_connect().  Please install the MySQL Connector for PHP');
    if ($zf_pconnect != 'false') {
      $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
    } else {
    // pconnect disabled ... leaving it as "connect" here instead of "pconnect"
      $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
    }
    if ($this->link) {
      if (@mysql_select_db($zf_database, $this->link)) {
        $this->db_connected = true;
        return true;
      } else {
        $this->set_error(mysql_errno(),mysql_error(), $zp_real);
        return false;
      }
    } else {
      $this->set_error(mysql_errno(),mysql_error(), $zp_real);
      return false;
    }
  }

to

function connect($zf_host, $zf_user, $zf_password, $zf_database, $zf_pconnect = 'false', $zp_real = false) {
//@TODO error class required to virtualise & centralise all error reporting/logging/debugging
    $this->database = $zf_database;
    if (!function_exists('mysql_connect')) die ('Call to undefined function: mysql_connect().  Please install the MySQL Connector for PHP');
    if ($zf_pconnect != 'false') {
      $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
    } else {
    // pconnect disabled ... leaving it as "connect" here instead of "pconnect"
      $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
    }
    if ($this->link) {
      if (@mysql_select_db($zf_database, $this->link)) {

            if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
            mysql_query('SET NAMES "utf8"', $this->link);}
         
       $this->db_connected = true;
        return true;
      } else {
        $this->set_error(mysql_errno(),mysql_error(), $zp_real);
        return false;
      }
    } else {
      $this->set_error(mysql_errno(),mysql_error(), $zp_real);
      return false;
    }
  }

4.You must ensure that your bulgarian.php defines are written in utf-8 or they will come up as monkeys :)

2 Sep 2007, 11:51 AM
#6
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Its also a good idea to take a look at your mysql tables using phpmyadmin or some other mysql administrator tool and see if your cyrillic symbols are displayed correctly.

2 Sep 2007, 2:22 PM
#7
ronson avatar

ronson

New Zenner

Join Date:
Oct 2006
Posts:
20
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Thanks a lot, it turned out that the collation of my database/tables was wrong. Now that is corrected, my simple and advanced searches are working fine.

It is interesting to note that the search is working without modifying query_factory.php

8 Dec 2007, 12:50 PM
#8
stefanb avatar

stefanb

New Zenner

Join Date:
Jul 2007
Posts:
18
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Hi, I had the same problem, and I solved it as I changed my site to utf-8, and followed your steps. However there came another problem. Almost everywhere in Bulgarian part there is "Your profile was created" instead for example "Welcome to our shop!" and "Home: creating profile" instead "Home : advanced search". In English this is OK Any help is appreciated.

16 Jan 2008, 8:35 AM
#9
saskvo4 avatar

saskvo4

New Zenner

Join Date:
Aug 2007
Posts:
10
Plugin Contributions:
0

Re: UTF8 problems with Advanced Search

Check the files in "includes/languages/bulgarian/your_template/" and "includes/languages/your_template/bulgarian.php" maybe they are not translated correctly.