Jump to content

Search : match query to end of words? (1.4 +)


Recommended Posts

The search in PS matches the searched string only to the beginning of the string. For instance, if I have a product named 'animal' and I search for 'mal' I won't get any results, only if I search for 'ani' for instance.

I managed to fix this in prestashop 1.3 by modifying the find module in the Search class. From

AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').'


to

AND sw.word LIKE '.($word[0] == '-' ? ' \'%'.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').'



ie the sql looks like

%query%

instead of just

query%



This doesn't work in 1.4 however. Any ideas how to get around this?

Link to comment
Share on other sites

×
×
  • Create New...