How to Improve Prestashop Search Results

May 5, 2014136Alex Simonchik
How to Improve Prestashop Search Results

I found out a problem. If your store has a product with an article ABC12345, you can find it inserting in search field ABC12345, ABC123, ABC1 and so on. But if you write there 12345 or 123, there’s going to be no results. Regular phrases like * do not work. Is there any other way to find product with 12345?

I have a solution. We need to redefine method find of Search class. In sql-request that does the search process you need to add %-symbol at the beginning of the line, that we are searching for. Find in file classes/Search.php this code:

And change it for that:

It’s better to override the file  classes/Search.php.

I have this part of the code from 209th line.

Post on the forum.


  1. чуть ниже тоже желательно поправить

    if ($word[0] != ‘-‘)
    $score_array[] = ‘sw.word LIKE \’%’.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).’%\”;

  2. I’m followed your guide but it seems that nothing happened on PS1.6.0.9.
    I also tried to empty the cache. There’s something else that i should do?

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *