prunica Posted September 24, 2012 Share Posted September 24, 2012 Hi, I have a little problem with prestashop search engine. I use 1.4.9 version and for example i have a product "yamaha rx-v373". If i type in search box the product name, it appears but if i type for example v373 or just 373 doesn';t show me this product. I set the product Product name weight to 10 in Preferences--> Searh and Minimum word length to 1. I have reindexd the products but no result. Please can someone advise me if is a simple method to solve this? otherwise i should change the search php to search only in title. PS in backend if i type 373 or v373 it works, the product appears. Thanks Stefan. Link to comment Share on other sites More sharing options...
vekia Posted September 24, 2012 Share Posted September 24, 2012 You can define search aliases in back office.I know this does not solve the problem completely, but until you solve the problem, you can use this as a temporary solution. 1 Link to comment Share on other sites More sharing options...
prunica Posted September 24, 2012 Author Share Posted September 24, 2012 (edited) You can define search aliases in back office.I know this does not solve the problem completely, but until you solve the problem, you can use this as a temporary solution. Thanks, you have right, is just a temoporary solution, i have at least 4000 products and many of them are simillar, i can't do it manually for all of them. Edited September 25, 2012 by prunica (see edit history) Link to comment Share on other sites More sharing options...
prunica Posted September 26, 2012 Author Share Posted September 26, 2012 Anyone having this problem please? Link to comment Share on other sites More sharing options...
prunica Posted September 27, 2012 Author Share Posted September 27, 2012 To solve this problem open the file classes/Search.php Search the "find" function. There you will have something like $intersectArray[] = 'SELECT 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.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] != '-') $scoreArray[] = 'sw.word LIKE \''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; If you know some MySQL, you'll guess that this query searches only words starting with your searched term. In order to make it search words that start with it, but, also, end with it. So, you have to add 3 '%' characters after every like. So, the code will be: $intersectArray[] = 'SELECT 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.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] != '-') $scoreArray[] = 'sw.word LIKE \'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; Link to comment Share on other sites More sharing options...
faDdy Posted April 17, 2013 Share Posted April 17, 2013 Hi, prunica i tried your solution but after changing the code in search.php search bar not working anymore? can you please help? Thanks Link to comment Share on other sites More sharing options...
vekia Posted April 17, 2013 Share Posted April 17, 2013 Hi, prunica i tried your solution but after changing the code in search.php search bar not working anymore? can you please help? Thanks you use the same prestashop version as prunica? Link to comment Share on other sites More sharing options...
faDdy Posted April 17, 2013 Share Posted April 17, 2013 No i am using prestashop 1.4.8.2 Thanks for the reply Link to comment Share on other sites More sharing options...
Donia Posted May 24, 2013 Share Posted May 24, 2013 same problem, any hint? Link to comment Share on other sites More sharing options...
Recommended Posts