ZikmaSolutions Posted March 16, 2017 Share Posted March 16, 2017 HI guys, Can you help me with this? I am ussing PrestaShop™ 1.6.0.13. How to make that Search works with "-" or "+". I have product named: "Battery A++" they mostly search for A++ . How i can fix this? Thanks Link to comment Share on other sites More sharing options...
ZikmaSolutions Posted March 29, 2017 Author Share Posted March 29, 2017 Still need help! Thanks! Link to comment Share on other sites More sharing options...
Casper_O Posted August 24, 2017 Share Posted August 24, 2017 Hi have you managed to find a solution? We have similar issues with our stores, where we sell items that cointains ":" and "+" in our names Link to comment Share on other sites More sharing options...
Scully Posted August 24, 2017 Share Posted August 24, 2017 (edited) First of all: the issue described here is not a bug. It's intention to give the most appropriate search results back. And special characters are difficult to handle in this context. The detault behavior of the search engine is to split up search terms which special characters, like for example - / + and others. The search term AAA-BBB results then in two words to search for: AAA and BBB. The special character(s) "get lost" during this preparation step. Changes are to be made in /classes/Search.php, there the defines for PREG_CLASS_SEARCH_EXCLUDE or PREG_CLASS_PUNCTUATION should be looked at. Probably the indexation would also need changes at another piece of code. Edited August 24, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Casper_O Posted August 24, 2017 Share Posted August 24, 2017 Hi and Thanks for the reply. I found out after a few hours searching and now I just need to figure out the correct hex value and remove the "right" one.... Do you have any clues about what the "-" is doing in these PREG ? As far I know they are not part of the hex values? Link to comment Share on other sites More sharing options...
Scully Posted August 24, 2017 Share Posted August 24, 2017 (edited) Checking the code, I'd say it's in the sanitizer function. Search for this code which starts at appx. line #109, note my 3 lines which are commented out by // at the beginning. if ($indexation) { // $string = preg_replace('/[._-]+/', ' ', $string); } else { $words = explode(' ', $string); $processed_words = array(); // search for aliases for each word of the query foreach ($words as $word) { $alias = new Alias(null, $word); if (Validate::isLoadedObject($alias)) { $processed_words[] = $alias->search; } else { $processed_words[] = $word; } } $string = implode(' ', $processed_words); $string = preg_replace('/[._]+/', '', $string); // $string = ltrim(preg_replace('/([^ ])-/', '$1 ', ' '.$string)); $string = preg_replace('/[._]+/', '', $string); // $string = preg_replace('/[^\s]-+/', '', $string); } Untested: Make a copy of your file before starting with changes. Probably a re-indexation is needed. Edited August 24, 2017 by Scully (see edit history) 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