1

I was wondering if there is a way to exclude certain words from a search in Magento. For example if I had three products:

Red Car
Big Car
Nice Car (great names I know)

So if someone searched 'red car', I only want them to see the 'red car' product in the search results and not the other two products with 'car' in the title.

Can anyone help me with this?


I realise there is already a post on this:

https://stackoverflow.com/questions/6691841/magento-exclude-search-term

However, it doesn't seem to be answered other than by editing the PHP file. I'm not au fait enough with PHP to write a method to do this...

Many thanks in advance! :-)

4
  • Welcome to Magento Stack Exchange! What have you tried? Commented Mar 10, 2014 at 13:21
  • Hi Fabian! Well I have my search set to 'Like' which is working perfectly for the rest of the store. It's really just a case of removing a certain word as I have lots of products that have 'series' in the name (it was 'car' in my earlier example!) and I'm not really sure where to start on how to remove it from every search. Thanks!
    – civiliam
    Commented Mar 10, 2014 at 13:41
  • And now its Magento GOne... Start thinking about migration. Commented Aug 9, 2014 at 5:02
  • 4
    This question appears to be off-topic because it is about magento-go which is closed now
    – Flyingmana
    Commented Nov 11, 2014 at 1:16

1 Answer 1

3

Use Solr

This is a good question, actually, and one that I would recommend using Solr to solve.

In the Solr search engine you can define exclusion words - called stop words - words that are common in language (the, there, for, but, these).

The best part is that these words are included in a file called stopwords.txt. Modifying this file and restarting the Solr engine allows you to edit any word in the list of exclusions.

Add the word "car" to stopwords.txt

If that doesn't solve it, make sure the following line is in your solr.conf:

<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />

I don't want Solr

If you're dead-set against Solr, or want to try something else first - the easiest method to handle this without writing any code at all is to remove the word "Car" from your product's name entirely. There are a couple ways of doing this, but the easiest would be from within your theme's product view template to append the word "Car" to products with a certain attribute set. (This is kind of a hack, yes. This is why I recommend Solr.) This prevents the word 'car' from being indexed as your product's name. Searches containing the word car should be a bit more relevant.

The opposite approach will also work - remove the color name from the product name itself, use it as a product attribute instead and concatenate it as a part of the product name.

5
  • Thanks for the suggestions. I'm pretty new to Magento and haven't heard of Solr before. At a quick glance it seems it's for Magento Enterprise? I'm working on Magento Go...
    – civiliam
    Commented Mar 10, 2014 at 15:25
  • Solr is available with connector modules for Community Edition as well; but being on Magento Go brings about a special issue as I'm not sure what you'll be able to do to modify the theme. You probably have very little room for improvement here - I would contact Go support.
    – philwinkle
    Commented Mar 10, 2014 at 15:32
  • Ok thanks I'll have a look into it. If I were to go down the modifying the code route instead, would there be a way to just exclude the word via a line of PHP somewhere? Thanks!
    – civiliam
    Commented Mar 10, 2014 at 15:59
  • Fiasco, this only became clear after the answer was posted. I edited the q to reflect the new information.
    – philwinkle
    Commented Mar 10, 2014 at 18:11
  • If I remember correctly, the SOLR modules for EE and CE don't allow using SOLR 4.x. Is this still the case?
    – pspahn
    Commented Aug 9, 2014 at 1:46

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