Guest Posted October 3, 2006 Share Posted October 3, 2006 Hello, I've found that if I put in a search for 'table' I get anything back with table as part of the word, like vegetables. Or if you put in 'hog', you get mahogany. I'm using CC for a shop that sells miniatures (like scale models and the like) so the range of products is vast, from furniture (tables) to miniature food (vegetables). Is there a way of only having complete word matches returned? Many thanks, and I really hope someone can help. Cheers! Quote Link to comment Share on other sites More sharing options...
roban Posted October 3, 2006 Share Posted October 3, 2006 Edit includes/content/viewCat.inc.php, around line 102. Change: if(($ucSearchTerm!=="AND") || ($ucSearchTerm!=="OR")){ To: if(($ucSearchTerm!=="AND") && ($ucSearchTerm!=="OR")){ Quote Link to comment Share on other sites More sharing options...
Guest Posted October 6, 2006 Share Posted October 6, 2006 Thanks Roban, but I checked the file and it already has that - any other ideas? Thanks for the response Quote Link to comment Share on other sites More sharing options...
Guest Posted October 29, 2006 Share Posted October 29, 2006 Hello, I've found that if I put in a search for 'table' I get anything back with table as part of the word, like vegetables. Or if you put in 'hog', you get mahogany. I'm using CC for a shop that sells miniatures (like scale models and the like) so the range of products is vast, from furniture (tables) to miniature food (vegetables). Is there a way of only having complete word matches returned? Many thanks, and I really hope someone can help. Cheers! Hi, I'm currently building a site with cubecart 3.0.13 and wanted to do an exact word/complete word search for my product range eg the whole word "red" but not match "credit"... here are the changes I made to get it working. Changes were made to includes/content/viewCat.inc.php ADD after: for ($i=0; $i<$noKeys;$i++) { THE following: if(strlen(trim($searchArray[$i])) == 0) { continue; } The above addition means that empty search terms are ignored eg spaces at the begining or the end of a search query (" red and green" OR "red and green ") CHANGE the following query: $like .= "(name LIKE '%".$searchArray[$i]."%' OR description LIKE '%".$searchArray[$i]."%' OR productCode LIKE '%".$searchArray[$i]."%') OR "; TO: $like .= "(name REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]' OR description REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]' OR productCode REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]') OR "; The above change adds two markers, they stand for word boundaries. They match the beginning and end of words, respectively. FOR EXAMPLE: "This product is red." vs "Buy this product with a credit card.".... in the first example "red" is an isolated word because it is surrounded by non-alphabetic and/or non-numeric characters, in this case it is a "space" on the left and a "full-stop" on the right. Whereas in the second example "red" (part of the word "credit") is surrounded by alphabetic characters and therefore is not a whole/exact word, in this case "c" on the left and "it" on the right. See the attached file for a diff formatted patch file.viewCat_inc_php.txt 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.