Editing the search function

I changed my search function before to basically search for anything in the product that matches what is inputted into the search bar.



Well its pulling up way to many results!



If you type in oil filter, it pulls up anything that has these letters in a row up. 100's of results.



This is to many and is not efficient.

I cant remember where I edited this at in cs-cart but also I don't know what I need to edit.



I want my search function to look at the part number and the search words.



How do I do this and where?

To search by Product Code, edit core/fn.catalog.php



Starting at line 6105 (v3.0.6), after the pname parameter, before the pshort parameter, I inserted the Search by Product Code:



$oc_codes = db_get_fields(" SELECT product_code FROM ?:product_options_inventory");
if (in_array($piece, $oc_codes)) {
$pid = db_get_field(" SELECT product_id FROM ?:product_options_inventory WHERE product_code = '$piece'");
$tmp .= db_quote(" OR products.product_id LIKE ?l", "%$pid%");
}
if ($params['pname'] == 'Y') {
$tmp .= db_quote(" OR products.product_code LIKE ?l", "%$piece%");
}




To eliminate the Full Description from the search results, you might want to look at this:

/skins/skinname/customer/common_templates/search.tpl Line 6:






I only search on name, keywords and product id. Full description returns too many irrelevant results.



[color=#0000FF]Don't forget to clear your cache after the template change.[/color]

Now you said this for 3.0.6 but I have v3.0.3.



When I look for the pname and pshort, I find it starting on line 6049.



And just to make clear, Id really like to just be able to search for product code, title, and search words.



The product code I know already works cause I changed that last year.

Cant remember how but It was done.



Just would like it to stop searching in the description and start searching in the title and search words.





//if perform search we also get additional fields
if ($params['pname'] == 'Y') {
$params['extend'][] = 'product_name';
}
if ($params['pshort'] == 'Y' || $params['pfull'] == 'Y' || $params['pkeywords'] == 'Y') {
$params['extend'][] = 'description';
}
unset($_condition);

I figured out what I need to be done.



How do I get the search function to look for all of the words being put into the search field and not just some of the words.



When I put in oil filter. The results bring up everything with the word oil, and filter in the title up.

Its also bringing up items such as “coil” which has the word " oil" in the word.



So what do I need to change to get the search to look for exact words?