Troubleshooting - Search

From Zen Cart(tm) Wiki
Jump to: navigation, search

This page deals with issues related to the search feature in the Zen Cart™ front-end.


Important: Make sure your products are added correctly from Admin - Catalog - Categories/Products. For example, all products must be located inside a category, but not the top category, otherwise the search won't work.


Case sensitivity

Info.png Search terms are always lowercase
Note that Zen Cart™ will transform search criteria into lowercase before searching the database, so searching for "My Product" is the same as searching for "my product".


Symptom

A search for my does not return a product named My product (note the uppercase M in the products name), however, a search for my product will return the product, because it matches product.


Cure

This solution is for Zen Cart™ 1.2.6d.


The following cure is more of a workaround than a solution to the entire problem, because we haven't been able to properly indentify the cause yet. It is however a database issue. If anyone think they might know something about this, please use the discussion page for this article or replace the following solution if you're absolutely certain.


Open

includes/blocks/blk_advanced_search_result.php

and replace

          default:
           $where_str .= "(pd.products_name like '%" . addslashes($search_keywords[$i]) . "%' or p.products_model like '%" . addslashes($search_keywords[$i]) . "%' or m.manufacturers_name like '%" . addslashes($search_keywords[$i]) . "%'";
// search meta tags
           $where_str .= " or (mtpd.metatags_keywords like '%" . addslashes($search_keywords[$i]) . "%' and mtpd.metatags_keywords !='')";
           $where_str .= " or (mtpd.metatags_description like '%" . addslashes($search_keywords[$i]) . "%' and mtpd.metatags_description !='')";
           if (isset($_GET['search_in_description']) && ($_GET['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . addslashes($search_keywords[$i]) . "%'";
             $where_str .= ')';
           break;

with

          default:
           $where_str .= "(lower(pd.products_name) like '%" . addslashes($search_keywords[$i]) . "%' or lower(p.products_model) like '%" . addslashes($search_keywords[$i]) . "%' or lower(m.manufacturers_name) like '%" . addslashes($search_keywords[$i]) . "%'";
// search meta tags
           $where_str .= " or (lower(mtpd.metatags_keywords) like '%" . addslashes($search_keywords[$i]) . "%' and mtpd.metatags_keywords !='')";
           $where_str .= " or (lower(mtpd.metatags_description) like '%" . addslashes($search_keywords[$i]) . "%' and mtpd.metatags_description !='')";
           if (isset($_GET['search_in_description']) && ($_GET['search_in_description'] == '1')) $where_str .= " or lower(pd.products_description) like '%" . addslashes($search_keywords[$i]) . "%'";
             $where_str .= ')';
           break;