dusty_much Posted May 5, 2013 Share Posted May 5, 2013 (edited) Hey guys, I am trying change the product search box, so that when a customer searches using the unique product reference, ONLY that product will show up. At the moment, the product that is being searched for, plus other similar products show up. For example, if a customer searches for NE 1001, 50 products show, with products that have similar references (eg SGI 1001 and NE 1002) also being shown. I want it to show ONLY the product with the reference that is being searched for. At the very least, I want the product with the correct reference being shown first. I am running Prestashop version 1.4.7.3 Thank you everyone for your help! Edited May 6, 2013 by dusty_much (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted May 6, 2013 Share Posted May 6, 2013 Hi Dusty. You need to create a system from scratch, as the basic search form will always look for keywords using LIKE. Now, I suggest you create a new module. In the hooking function, wehen the 'submit_reference' name is passed, select from the database a product with the same identical reference. You might want to use Search::sanitize to be sure it's clean. Notice it wil absolutely need to be identical to your reference, to use '=' instead of LIKE. If there is a match, use $Link->getProductLink('$id_product....) to get the link, and the header(Location:....) to redirect the user, or Tools::redirect() Fabio Link to comment Share on other sites More sharing options...
dusty_much Posted May 6, 2013 Author Share Posted May 6, 2013 Hey Fabio, Thanks so much for your reply. I actually found a way to do what i wanted. I edited the search.php class and before the results array was returned I added in some code to check each entry in the array, to see whether the reference was the one I was looking for. If such a reference was found, I only returned that array entry and nothing else. If not, the whole array was returned as usual. I hope this helps anyone else who has this problem, I will make sure to mark this post as solved now. 1 Link to comment Share on other sites More sharing options...
NemoPS Posted May 6, 2013 Share Posted May 6, 2013 Not a bad idea at all! Of course, if you only look for the ref, it can be quicker, and you can possibly have 2 search types Link to comment Share on other sites More sharing options...
veravalonline Posted July 2, 2013 Share Posted July 2, 2013 is there any search module that can search even the site content, Link to comment Share on other sites More sharing options...
fredecs Posted July 14, 2023 Share Posted July 14, 2023 I have made that. Just edit the file classes/Search.php and change the line: if (!$psFuzzySearch || $fuzzyLoop++ > $fuzzyMaxLoop || !($sql_param_search = static::findClosestWeightestWord($context, $word))) { to if (!$psFuzzySearch || $fuzzyLoop++ > $fuzzyMaxLoop) { That's it! You will only find the product with the exact referente. 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