Improve CS search capability by searching the products keywords
and meta description if required.
Edit : line 131 of /include/common/search_products.php
foreach ($pieces as $piece) {
$tmp = array();
[COLOR=red]// SWS MOD TO SEARCH PRODUCT KEYWORDS AND META DESCRIPTION
$tmp[] = "descr1.meta_keywords LIKE '%$piece%'";
$tmp[] = "descr1.meta_description LIKE '%$piece%'";
// END SWS MOD HERE [/COLOR]
if ($search_data['search_product_name'] == 'Y') {
$tmp[] = "descr1.product LIKE '%$piece%'";
}
}
Above that code (approx line 115) I couldnt find in the admin where to change this so I modified the code…
[COLOR="Red"]// SWS MOD TO FORCE ALL SEARCH !
$search_data['match'] = 'all' ;
// SWS MOD[/COLOR]
if (!empty($search_string)) {
Ive had another play around to improve the search, so far Ive come up with an ugly hack but its still better than showing the “no products found” message
Basically I have cloned the following file
/includes/common/search_products.php
to
/includes/common/search_products2.php
In the first file, I have set the match type to All
// SWS MOD TO FORCE ALL SEARCH !
$search_data['match'] = 'all' ;
// SWS MOD
if (!empty($search_string)) {
Anythings possible, however to be honest it may be worth waiting for their next release to see what they have up their sleeve first.
Search was annoying a little, but then its not just CS cart which suffers from this, a lot of things do. Also using operators for searching isnt common knowledge for the general public
[quote name=‘SWS’]Improve CS search capability by searching the products keywords
and meta description if required.
Edit : line 131 of /include/common/search_products.php
foreach ($pieces as $piece) {
$tmp = array();
[COLOR=red]// SWS MOD TO SEARCH PRODUCT KEYWORDS AND META DESCRIPTION
$tmp[] = "descr1.meta_keywords LIKE '%$piece%'";
$tmp[] = "descr1.meta_description LIKE '%$piece%'";
// END SWS MOD HERE [/COLOR]
if ($search_data['search_product_name'] == 'Y') {
$tmp[] = "descr1.product LIKE '%$piece%'";
}
}
This the modified code… please suggest us that it has been done correctly
foreach ($pieces as $piece) {
$tmp = array();
if ($search_data['search_product_name'] == 'Y') {
$tmp[] = "descr1.product LIKE '%$piece%'";
}
if ($search_data['search_short_description'] == 'Y') {
$tmp[] = "descr1.short_description LIKE '%$piece%'";
}
if ($search_data['search_full_description'] == 'Y') {
$tmp[] = "descr1.full_description LIKE '%$piece%'";
}
if ($search_data['search_meta_keywords'] == 'Y') {
$tmp[] = "descr1.meta_keywords LIKE '%$piece%'";
}
if ($search_data['search_meta_description'] == 'Y') {
$tmp[] = "descr1.meta_description LIKE '%$piece%'";
}
if (is_array($search_data['search_product_features']) && $action != 'feature_search') {
$tmp[] = "$db_tables[product_features_values].value LIKE '%$piece%'";
}
The Search Words field is used to specify additional words that will be included when using CS-Cart’s product search.
One example would be including a frequent misspelling in the Search Words field. For example, you sell dust ruffles but you might also see that people often incorrectly type “ruffel” when doing a search. You could include “ruffel” in the Search Words for all your dust ruffle products and then all those products would be displayed even when your customer misspelled that word. You could also use it for abbreviations or “aliases” used to refer to your product.
You can find the search words your customers are using in Admin->Statistics:Product Search.