SuperDuper Posted February 13, 2013 Share Posted February 13, 2013 (edited) Hello, Using v1.5.3.1 For example, there is a product "SE3761" We can only search the Full text "SE3761" to obtain this result. How can we modify that if I search only "3761" also can find this product?? Thank you. Edited February 17, 2013 by SuperDuper (see edit history) Link to comment Share on other sites More sharing options...
Vic360v Posted February 14, 2013 Share Posted February 14, 2013 Hi, You can use the Alias function. (Preferences > Search) Hope it helps. Link to comment Share on other sites More sharing options...
CameraTek Posted February 14, 2013 Share Posted February 14, 2013 (edited) I have the same problem. If I search for "hx20v" it comes back with nothing. But if I search for "dsc-hx20v" it comes with 2 results. In the back office I do a search for hx20v, comes back with 4 results. Why's the back office search better than the front office search? I'm also using 1.5.3.1 Andy Edited February 14, 2013 by CameraTek (see edit history) Link to comment Share on other sites More sharing options...
SuperDuper Posted February 15, 2013 Author Share Posted February 15, 2013 Hi, You can use the Alias function. (Preferences > Search) Hope it helps. Hello, thanks for your reply. It works, but there are many items in my shop. Actually I can not add Alias manually for all items. Can we modify the .php to achieve it? Thanks again. Link to comment Share on other sites More sharing options...
Vic360v Posted February 16, 2013 Share Posted February 16, 2013 Then, you can modify the file (.../classes/search.php) to substring all the searches with (%) variable or whatever you want. From line 190 to 197 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)).'%\''; Like this 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)).'%\''; But with this the search makes much more effort and the performance probably will be affected or can cause an overload. it would be better to use something like a wildcard, but I don't know of any on presta. Link to comment Share on other sites More sharing options...
SuperDuper Posted February 17, 2013 Author Share Posted February 17, 2013 Then, you can modify the file (.../classes/search.php) to substring all the searches with (%) variable or whatever you want. From line 190 to 197 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)).'%\''; Like this 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)).'%\''; But with this the search makes much more effort and the performance probably will be affected or can cause an overload. it would be better to use something like a wildcard, but I don't know of any on presta. Wow!! Fantastic, it works. Now we can search the items in substring text. Thank you. [sOLVED] 1 1 Link to comment Share on other sites More sharing options...
tis-marketer Posted February 22, 2013 Share Posted February 22, 2013 Hi, We've done this and it somehow works but now I have so many results. lol For example: Search term: HP 092A Search results: Brother 350, Brother 360,....... until I go to page 7... and that's the time "HP" appears. What I mean is that - is it possible for the search results to just prioritize the "HP"? Because what happened with the results is that it even though I key in HP, it still displayed "Brother" items. Please help. Link to comment Share on other sites More sharing options...
Vic360v Posted February 24, 2013 Share Posted February 24, 2013 Hi, We've done this and it somehow works but now I have so many results. lol For example: Search term: HP 092A Search results: Brother 350, Brother 360,....... until I go to page 7... and that's the time "HP" appears. What I mean is that - is it possible for the search results to just prioritize the "HP"? Because what happened with the results is that it even though I key in HP, it still displayed "Brother" items. Please help. Did you try to use the weight function? (preferences>search) you can give a greater weight to the name i.e. (or where you think it would be better) Anyways i do not recomend you to use this code in your case, because it gives a lot of work to the search engine. instead you can use the tags or the alias to make the search more efficient. Regards. Link to comment Share on other sites More sharing options...
tis-marketer Posted February 25, 2013 Share Posted February 25, 2013 Hi Vic, Thanks for the reply. I tried the weight - the name is already at 10, the others are 1, the results are still the same. What's the maximum number for weight? I'd love to use the alias and tags but I have over 8000 products... Link to comment Share on other sites More sharing options...
trevorgilligan Posted February 11, 2015 Share Posted February 11, 2015 does anyone know how to fix so that: product name = "abc" search "abc" works search "abc def" or "def abc" no result?? thanks trev Link to comment Share on other sites More sharing options...
Gipielle Posted February 20, 2017 Share Posted February 20, 2017 (edited) is there a way to add % and make search also faster ? Edited March 22, 2017 by Gipielle (see edit history) Link to comment Share on other sites More sharing options...
Victor Castro Contreras Posted July 22, 2020 Share Posted July 22, 2020 Al fin logré encontrar la solución al problema de las búsquedas en Prestashop para usar el LIKE en la búsqueda de productos 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