How to find a product with exact match in Magento Search?

There are two search criteria in Magento:

  1. AND (exact match) - it means that search will be implemented by the entire search phrase, for instance, if you type in search field phrase Sony VAIO you will be given only the results for Sony VAIO.
  2. OR (not exact match) - it means that search will be implemented by specific word in a search phrase, for instance, if you type in search field phrase Sony VAIO, acsept Sony VAIO you will be given results on each word separately.

In order to set up an exact match in Magento Search for version 1.7 follow next steps. Open fulltext.php file which you can find following the path App/Code/Core/Mage/CatalogSearch/Model/Resource/. Change the value OR to AND in 330 line:

if ($like) {
   $likeCond = '(' . join(' OR ', $like) . ')';

into this:

if ($like) {
   $likeCond = '(' . join(' AND ', $like) . ')';

Change OR to AND in 355 line

if ($likeCond != '' && $searchType ==
    Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
        $where .= ($where ? ' OR ' : '') . $likeCond;  

into this:

if ($likeCond != '' && $searchType == 
    Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
        $where .= ($where ? ' AND ' : '') . $likeCond;

Save the changes, now you need to take the final step to set up an exact match in Magento Search, open Magento Admin Panel and change the type of search to FullText. Follow the path:  Admin Panel > Configuration > Catalog > Catalog > Catalog Search.

Magento Search

After you`ve done, you will have your exact match seach set up in Magento Search.

But if you are not satisfied with an exact match in  Magento Search by default and you need something more than a standard search, but better relevance and additional functions, we recommend you to use an extansion from our developers - Sphinx Search Ultimate. An extension provides you with a product search in your e-store to be almost perfect.

Loading...