1

(Warning: NSFW website. 18+)

The search panel on my company's website seems to be searching for individual words rather than for the query entered.

For example, when I search for o ring 104 products come back in the search results (whereas we sell less than 10 items with the words 'o ring' in the title) (http://rougegarments.co.uk/catalogsearch/result/?q=o+ring)

How would I go about changing this to search for query as opposed to specific terms. I am running the Buyshop ver 2.3.1 Theme in Magento.

Any help is much appreciated :)

2

Magento default search uses OR to search, so it searches for things containing "o" or "ring". To make this an AND search, the easiest (yet not cleanest) solution is as follows:

Make a copy of app/code/core/Mage/CatalogSearch/Model/resource/Fulltext.php and place it: app/code/local/Mage/CatalogSearch/Model/resource/Fulltext.php

On about line 356 you will find

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

Change that to:

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

Then about line 378 find

$where .= ($where ? ' OR ' : '') . $likeCond;

Change that to:

$where .= ($where ? ' AND ' : '') . $likeCond;

Now, go to the backend and reindex your search index in the indexer section. Afterwards, your search should be using AND instead of OR search.

| improve this answer | |
  • Thanks for the comment. I found the fulltext.php file in core but the folder CatalogSearch doesn't seem to exist in the local folder? – Paul_Rouge Jul 18 '14 at 13:25
  • @Paul_Rouge You have to create the folders in local! – mpaepper Jul 19 '14 at 7:44
1

You can do this from Magento Admin

1) Goto System->Configuration->CATALOG->Catalog->Catalog Search

2) Make Search Type as either LIKE or Combine(LIKE and FULLTEXT)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.