Prestashop: Allow wildcard search

The search index indexes on individual words and as it is now, wants you to give a search word from the beginning of the word.

To fix this, we need to edit the file Classes/Search.php

to fix this, change the code a little like this: (find the lines in the code above and add the % three times:

? ' \'%'.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
: '\'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''

if ($word[0] != '-')
 $score_array[] = 'sw.word LIKE \'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'';
This entry was posted in ecommerce and tagged , . Bookmark the permalink.