keat Posted July 27, 2017 Share Posted July 27, 2017 Trying to search for something which might be 2.5mm and nothing shows. It will show me all items which are 25mm, but nothing which is 2.5mm. Any thoughts ? Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 27, 2017 Share Posted July 27, 2017 In /classes/catalogue.class.php, near line 1806 (CC618), THERE IS: $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u', '', $search_data['keywords']); Note that there is no punctuation in the class of characters (enclosed in brackets), so the period will be removed. If this is character is important, try adding it. The above is relevant to CubeCart's first search attempt - 'fulltext'. If there are no results, CubeCart makes a second attempt using 'rlike' - a whole-word search. The entered keyword phrase is split on spaces and commas, and the resulting array now comprises whole words whatever characters they may contain. If still no results, CubeCart makes a third attempt using 'like' - a match of a partial word to be found in any part of the haystack. Such as 'one' being found in 'honey'. Quote Link to comment Share on other sites More sharing options...
keat Posted July 28, 2017 Author Share Posted July 28, 2017 I'm not exactly sure where to add it, so I added it directly after the u, it now seems to find 2.5mm items Thanks. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 28, 2017 Share Posted July 28, 2017 Try this: $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s.]+/u', '', $search_data['keywords']); Quote Link to comment Share on other sites More sharing options...
keat Posted July 28, 2017 Author Share Posted July 28, 2017 (edited) How odd. I moved the period from after the 'u' to after the 's' as suggested and the search stopped finding 2.5mm, so I moved it back and it still won't find 2.5mm. Despite clearing the cache and my browser. Three or four attempts later, delete the file, ftp it back up, clear browser, clear cache and it works again. Edited July 28, 2017 by keat Quote Link to comment Share on other sites More sharing options...
keat Posted September 8, 2017 Author Share Posted September 8, 2017 I just discovered today, that this is breaking the search. Searching products, and i cannot scroll beyond page 1 of the results. If I use $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u.', '', $search_data['keywords']); (period after +/U) The search breaks If I use $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s.]+/u', '', $search_data['keywords']); (period after 9\s) The search doesn't detect the period. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 8, 2017 Share Posted September 8, 2017 REGEX rules discuss the concept of 'character classes'. Anything inside a set of brackets is treated as things to search for. There are a few special characters that must be escaped: \s for things like spaces, tabs, new lines, etc., a 'dash allows for ranges of characters, and a couple others. So, the period goes inside the brackets. Note that, just inside the opening bracket, there is a circumflex (^). This means to negate the class. This statement is wanting to replace any other character not in this class with nothing, that is, remove from the search string any character that is not in the class. We do not want the period removed. So, we need to look elsewhere why a search is not finding a product name/code/description with a period in it. Quote Link to comment Share on other sites More sharing options...
keat Posted September 11, 2017 Author Share Posted September 11, 2017 With the period placed after the u ( $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u.', '', $search_data['keywords']) ) I could find products containing the period. However, when doing a normal search, i couldn't progress beyond page one of the results. If I had 5 pages of results, choosing subsequent pages would only show the first page results. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.