hakeryk2 Posted April 6, 2020 Share Posted April 6, 2020 (edited) Hello devs and users, I was strugling with this really bad behavior of Prestashop search engine when ie: you were searching for "wooden chair" and You end up with result of products that contains "wooden" and "chair" as well. Which sucks ass. This was driving my crazy so I end up with this override for Search.php in Prestashop 1.6 - didn't tested this on 1.7. This piece of code checks whether product that You searched for contains both or more words in search index (like tags, featuers not only the name) that You actually searched. Now I can die peacefully because when somone was searching for ie: Black chair he don't ends up with bunch of black wardrobes, chairs, sofas etc but actually only black chairs. To get this working at least in a relevant way please use at least (product name, features, categories, tags) or combinations set in Preferences -> Search. After this rebuild Your cache. Try not to use description or short description because it contains to many words. To install this just put this file in override/classes/ and after this remove class_index.php file in cache folder. I hope You find it usefull. I was working on this for 6 hours because I had to understand how prestashop search engine works (by the way - why the f*** presta needs to get all products from shop before searching!?) and I had to do this as efficient and performative as I can so any tip will be appreciated. It works faster for me then previous one. Try it for yourself If someone will find a better way to do this after reading this code please share it as well. I need to edit the file because previous contained a lot of my own overrides to search categories, cms and other stuff as well - now it's a clean one Update: I found much more efficient and easier method to get this done Edited again. Search.php Edited June 5, 2020 by hakeryk2 (see edit history) 5 Link to comment Share on other sites More sharing options...
Ezequielb Posted April 7, 2020 Share Posted April 7, 2020 (edited) Hello, putting the file in override/classes is not working, how do I setup this file? Edited April 7, 2020 by Ezequielb (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted April 7, 2020 Author Share Posted April 7, 2020 You need to remove class_index.php file from cache folder after putting this override. It works for 1.6 - I didn't tested this on 1.7 but I think that devs can edit this without any problem to 1.7 and share with it here as well. 1 Link to comment Share on other sites More sharing options...
Ezequielb Posted April 14, 2020 Share Posted April 14, 2020 Thanks. It worked.. Link to comment Share on other sites More sharing options...
Ezequielb Posted April 18, 2020 Share Posted April 18, 2020 (edited) I don't know if its my PS only (PS 1.7.6.4), but search results are not filtered by reference number. If I have a product with 10 combinations for example: C100-00 -> default combination C100-01, C100-02, C100-03 ....etc. are other combinations. If I search for the combination C100-03, the search result brings me the default C100-00 combination option (links to default combination). That may be confusing for customers. I'd like to know if you have this problem solved. Best regards! Edited April 18, 2020 by Ezequielb (see edit history) Link to comment Share on other sites More sharing options...
EnterPL Posted April 19, 2020 Share Posted April 19, 2020 In 1.7.6.2 works. Thanks. 😀 1 Link to comment Share on other sites More sharing options...
i6n7fo Posted April 30, 2020 Share Posted April 30, 2020 Hi! Thanks a lot for your work! It solved half my issues. My PHP and SQL years are far away. Using your code, how could I exclude products of a category from the search results? A fast and dirty hack using a hard coded category id on line 95 wouldn't bother me. Best regards ! Link to comment Share on other sites More sharing options...
Ezequielb Posted May 3, 2020 Share Posted May 3, 2020 On 4/18/2020 at 2:56 PM, Ezequielb said: I don't know if its my PS only (PS 1.7.6.4), but search results are not filtered by reference number. If I have a product with 10 combinations for example: C100-00 -> default combination C100-01, C100-02, C100-03 ....etc. are other combinations. If I search for the combination C100-03, the search result brings me the default C100-00 combination option (links to default combination). That may be confusing for customers. I'd like to know if you have this problem solved. Best regards! Nobody? Link to comment Share on other sites More sharing options...
hakeryk2 Posted June 2, 2020 Author Share Posted June 2, 2020 (edited) Just to let You know folks - I edited this solution to be more effective. It is still precise but it can do more and faster. Feel free to upgrade it. Original file from first post is the one updated. First solution had much more queries then it suposse to has Edited June 2, 2020 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
i6n7fo Posted June 2, 2020 Share Posted June 2, 2020 This new version is broken on 1.7.5.1, I get a white page when searching. Link to comment Share on other sites More sharing options...
hakeryk2 Posted June 3, 2020 Author Share Posted June 3, 2020 I updated right now the top version but I cannot help You until You don't provide me an error from logs which You received. For 1.6.1.24 is working, I didn't test on 1.7 and I think it might be an issue because on 1.7.7 they added some new functionalities to search engine so even if You have lower version then it might be not the best thing for you. Link to comment Share on other sites More sharing options...
andrew Posted June 3, 2020 Share Posted June 3, 2020 Thanks for this - I will give it a go and give some feedback We've also been struggling - search was overloading our server, causing resource blocking - resulting in limited connections, resulting in errors - Andrew Link to comment Share on other sites More sharing options...
hakeryk2 Posted June 5, 2020 Author Share Posted June 5, 2020 Currently I am working on cache system for this to be able to cache most popular search results. I will upload this feature in some near future but any help will be appreciated. Damn, customers are really happy because they can find products not by their name but just by typing everything related to product Link to comment Share on other sites More sharing options...
Maryando Posted September 24, 2020 Share Posted September 24, 2020 (edited) Hi, I have moved the file to override/classes/ in my 1.7.6.2 version an as you advised deleted: /var/cache/prod/class_index.php. I can't see any changes in the search engine behaviour still works like before. I think this solution stull need a bit more work to suit PrestaShop 1.7 Thanks Edited September 24, 2020 by Maryando (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted September 25, 2020 Author Share Posted September 25, 2020 Actually I dunno because there was some search fixes as I mentioned 3 posts above. I made for 1.7 but few people here were able to make it on 1.7. I can't help you because I am not working on 1.7 Link to comment Share on other sites More sharing options...
Maryando Posted September 25, 2020 Share Posted September 25, 2020 Hi, Thanks no worries, however this the most annoying thing in Prestashop. Best Regards Link to comment Share on other sites More sharing options...
AKSE Posted November 30, 2020 Share Posted November 30, 2020 Thanks Hakeryk2! Working well on 1.6.1.23 Solved one of the most annoying things in PS. Link to comment Share on other sites More sharing options...
ukyoner Posted January 13, 2021 Share Posted January 13, 2021 (edited) On 4/6/2020 at 6:34 PM, hakeryk2 said: Hello devs and users, I was strugling with this really bad behavior of Prestashop search engine when ie: you were searching for "wooden chair" and You end up with result of products that contains "wooden" and "chair" as well. Which sucks ass. This was driving my crazy so I end up with this override for Search.php in Prestashop 1.6 - didn't tested this on 1.7. This piece of code checks whether product that You searched for contains both or more words in search index (like tags, featuers not only the name) that You actually searched. Now I can die peacefully because when somone was searching for ie: Black chair he don't ends up with bunch of black wardrobes, chairs, sofas etc but actually only black chairs. To get this working at least in a relevant way please use at least (product name, features, categories, tags) or combinations set in Preferences -> Search. After this rebuild Your cache. Try not to use description or short description because it contains to many words. To install this just put this file in override/classes/ and after this remove class_index.php file in cache folder. I hope You find it usefull. I was working on this for 6 hours because I had to understand how prestashop search engine works (by the way - why the f*** presta needs to get all products from shop before searching!?) and I had to do this as efficient and performative as I can so any tip will be appreciated. It works faster for me then previous one. Try it for yourself If someone will find a better way to do this after reading this code please share it as well. I need to edit the file because previous contained a lot of my own overrides to search categories, cms and other stuff as well - now it's a clean one Update: I found much more efficient and easier method to get this done Edited again. Search.php 9.03 kB · 35 downloads [edit] i have an error 500 with 1.61.13 Edited January 13, 2021 by ukyoner (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted January 15, 2021 Author Share Posted January 15, 2021 Well, if this 500 then we need to magic to figure it out. Only then we will be able to help if we will know what cause the issue and what error is saying. 1 Link to comment Share on other sites More sharing options...
Prestachamps Posted January 15, 2021 Share Posted January 15, 2021 Hi, Please enable debug mode and send us the error log there the 500 error should be described. Also, did you took the original Search class when created the override and modified that one for the overridden class? Kind regards, Leo Link to comment Share on other sites More sharing options...
Ezequielb Posted March 17, 2021 Share Posted March 17, 2021 @hakeryk2 can you solve this issue? When you search for a product using the reference number with a product that has 10 combinations and each combination has a reference number, the search results do not take you to the correct reference number but to the default combination. Can you shred some light to find a solution for this? Best regards! Link to comment Share on other sites More sharing options...
hakeryk2 Posted April 8, 2021 Author Share Posted April 8, 2021 Good idea, maybe I will fix this in future. I did not needed this in my shop but idea is quite clever. If I will make something about it I'll let you know. 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