Jump to content
Jack

prestashop 1.7.4.3 search not works for Chinese in front end

Recommended Posts

I cannot make search work in front end. After input some words and press enter, always no products found. Anyone else have the same issue using version 1.7.4.3? 

Share this post


Link to post
Share on other sites

After re-installed prestashop, I found the search function just works for English words, not for Chinese words. Anyone has an idea to fix it?

Share this post


Link to post
Share on other sites

Finally found the reason and a workaround:

In classes/Search.php, in function sanitize() at about line 167,

$string = Tools::replaceAccentedChars(trim(preg_replace('/\s+/', ' ', $string)));

replace it with,

$string = Tools::replaceAccentedChars($string);

Then searching works with Chinese words.

Notes: my version is 1.7.4.3

Share this post


Link to post
Share on other sites

Finally found the solution, just replace the line mentioned above with,

$string = Tools::replaceAccentedChars(trim(preg_replace('/[\pZ\pC]+/u', ' ', $string)));

Also, comment out lines about splitting symbols(also chinese characters) to single words, see attached file for details.

Then rebuild search index and everything will work.

Search.php

Share this post


Link to post
Share on other sites

Instead of using PrestaShop default search I prefer to use the Search Module available at the Addon store. It provides more options to improve the search results, it works good for my store. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More