Author Topic: VM search plugin - problem with language special char (ľ,š,č,ť...)  (Read 651 times)

caesarsk

  • Jr. Member
  • **
  • Posts: 50
Hi all,

I have a little problem with the VM search module.

Situation:
- I have product with title "čelenka"
- when my search string is "čelenka", module find him - this is ok
- but when I try "celenka" (č - c), module can not find the product

My question is:
- this is standard situation?
- when no, is problem with language settings? Shop language is slovak, but VM was installed in the EN language (I think)
- it is necessary to modify the search plugin?

thx

caesarsk

  • Jr. Member
  • **
  • Posts: 50
ok, I found solution. (J v3.8.8 + VM v3.2.14)

1. go to /plugins/search/ and duplicate (and rename e.g. virtuemartMod) folder "virtuemart"

2. rename files virtuemart.php and virtuemart.xml to e.g. virtuemartMod.php and virtuemartMod.xml

3. open virtuemartMod.xml and rename:
from
Code: [Select]
<filename plugin="virtuemart">virtuemart.php</filename>to
Code: [Select]
<filename plugin="virtuemartMod">virtuemartMod.php</filename>
4. open virtuemartMod.php rename class:
from
Code: [Select]
class plgSearchVirtuemart extends JPluginto
Code: [Select]
class plgSearchVirtuemartMod extends JPlugin
5. modily switch function about line 103 like this

Quote
      switch ($phrase) {
         case 'exact':
            $wheres2 = array();
            // product_sku should be exact match
            $text = $db->quote("%$text%", TRUE);
            $wheres2[] = "p.product_sku LIKE $text";
            $wheres2[] = "a.product_name COLLATE utf8_general_ci LIKE $text";
            $wheres2[] = "b.$category_field COLLATE utf8_general_ci LIKE $text";
            if ($search_product_s_description)
               $wheres2[] = "a.product_s_desc COLLATE utf8_general_ci LIKE $text";
            if ($search_product_description)
               $wheres2[] = "a.product_desc COLLATE utf8_general_ci LIKE $text";
            if ($search_customfields)
               $wheres2[] = "(cf.customfield_value LIKE $text $customfield_ids_condition)";
            $where = '(' . implode (') OR (', $wheres2) . ')';
            break;
         case 'all':
         case 'any':
         default:
            $words = explode (' ', $text);
            $wheres = array();
            foreach ($words as $word) {
               $wheres2 = array();
               // product_sku should be exact match
          $word = $db->quote("%$word%", TRUE);
               $wheres2[] = "p.product_sku LIKE $word";               
               $wheres2[] = "a.product_name COLLATE utf8_general_ci LIKE $word";
               $wheres2[] = "b.$category_field COLLATE utf8_general_ci LIKE $word";
               if ($search_product_s_description)
                  $wheres2[] = "a.product_s_desc COLLATE utf8_general_ci LIKE $word";
               if ($search_product_description)
                  $wheres2[] = "a.product_desc COLLATE utf8_general_ci LIKE $word";
               if ($search_customfields)
                  $wheres2[] = "(cf.customfield_value LIKE $word $customfield_ids_condition)";

               $wheres[] = implode (' OR ', $wheres2);
            }
            $where = '(' . implode (($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
            break;
      }

@milbo, it would not be bad to add COLLATE option to VM search.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
yes, quite easy todo, just some work. The param needs to be added to the xml and needs language keys and translation.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/