Barama Posted October 14, 2014 Share Posted October 14, 2014 The partial search in Prestashop seems broken. I have found 3 threads with the same problem as mine. http://www.prestashop.com/forums/topic/49430-search-not-working-right/?hl=%2Bpartial+%2Bsearch&do=findComment&comment=330576 http://www.prestashop.com/forums/topic/89997-search-problem/?hl=%2Bpartial+%2Bsearch http://www.prestashop.com/forums/topic/100766-partial-searches/?hl=%2Bpartial+%2Bsearch There is also a bug report: http://forge.prestashop.com/browse/PSCFV-11576 For example I have the word "Holzschatulle". If I type in "schatulle" it does not find the word "Holzschatulle". Does anyone know a workaround? Alternatively where can I change the query string? In /classes/Search.php ? Link to comment Share on other sites More sharing options...
fjblanque Posted November 21, 2014 Share Posted November 21, 2014 I have the same problem :S Please help!! Link to comment Share on other sites More sharing options...
Barama Posted November 21, 2014 Author Share Posted November 21, 2014 (edited) I forgot to mention how I solved it. You have to open /YourPrestashopRoot/classes/Search.php Go to the find() function. There change the first foreach() loop to this: foreach ($words as $key => $word) if (!empty($word) && strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN')) { $word = str_replace('%', '\\%', $word); $word = str_replace('_', '\\_', $word); $intersect_array[] = 'SELECT si.id_product FROM '._DB_PREFIX_.'search_word sw LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = '.(int)$id_lang.' AND sw.id_shop = '.$context->shop->id.' 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)).'%\'' ); if ($word[0] != '-') $score_array[] = 'sw.word LIKE \'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; } There is not much change except that I added 2 or 3 %-characters. This fixes the problem. I use Prestashop 1.6. Edited November 21, 2014 by Barama (see edit history) 1 Link to comment Share on other sites More sharing options...
Gipielle Posted February 20, 2017 Share Posted February 20, 2017 Thank you Barama ! three % solved the problem !! Great ! Link to comment Share on other sites More sharing options...
Gipielle Posted February 20, 2017 Share Posted February 20, 2017 It works but if there are many products in search it will takes long long time ... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now