I have attempted for quite a number of hours to solve this but I can't find the solution.

I want to allow users to search by certain attribute values, for example ingredients, brand OR product name. At the moment I can pass to the query string the type of search we are performing, e.g.


I have tried to modify the controllers and helpers in catalogsearch so I can pass this variable on and search for that filter, but I just can't figure out a way to do it.

I would still like to search by name too, so there will need to be a switch e.g.


Would need to search product name still.

Any tips for accomplishing this? I've been editing


for hours without any real progress.

Thanks :)

3 Answers 3


You can use this code to search product with many fields Below code is able to search by product name, description, using mysql LIKE syntax

//$data = search box input text

$products = Mage::getResourceModel('catalog/product_collection')
            ->setOrder('created_at', 'DESC')
                        'attribute' => 'name',
                        'like'        => '%'. $data->getQueryText().'%',
                        'attribute' => 'description',
                        'like'        => '%'. $data->getQueryText().'%',

            ->addExpressionAttributeToSelect('query_text', '{{name}}', 'name')
            ->addAttributeToFilter('visibility', $visibility)
                array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
  • Thanks for that, I was already able to achieve the results I wanted in another search module (it's an AJAX search suggestion feature) and that works perfect, but the issue was that CatalogSearch is so complicated I can't for the life of my figure out where I need to make the changes. Where would I set this up?
    – NJ.
    Commented Mar 5, 2015 at 23:24
  • Where did you put this file ? Which file did you modify? Please clarify thru edit. The answer is pretty complicated and not explanatory . Commented Jul 16, 2015 at 9:56
  • @PratikCJoshi, Check *Mage/CatalogSearch/Model/Query * you need to override it locally
    – Charlie
    Commented Jul 16, 2015 at 10:27
  • I saw that file but it has many (5) functions , which function to edit ? Commented Jul 16, 2015 at 11:02

I'm not sure I understand you correctly, but you can configure every attribute to be searchable.

Than you don't have to do anything.

Also you can configure an attribute to be searchable in advanced search, so you can search specifically in an attribute and not "over all".

  • Sorry, to clarify what I want is a way for users to ONLY search by one field, be it the name, the ingredient list or so forth (I will configure these). So I am trying to rewrite CatalogSearch to accept another parameter and then select the field to search based on this parameter.
    – NJ.
    Commented Mar 5, 2015 at 23:24
  • That is, users should select if they want to search via name or ingredients etc.
    – NJ.
    Commented Mar 5, 2015 at 23:30
  • Why not changing the form so you can only add one attribute? Then you only might want to make sure you can't search for something else Commented Mar 8, 2015 at 23:04

You might want to investigate using Solr search (even though you are on community). I was surprised by how easy it was to setup and you certainly can 'weight' searches by attribute matches, albeit this requires a little bit of reading the manual and experimentation to get the results you want.

This module looks pretty good:


It depends on your use case, but, give Solr a go and see if you can come up with an 'omnibox' of search, or use it in conjunction with regular search.

  • Wasn't really looking to use anything else. This is already a heavily modified site with themes and extensions, I was really hoping I could modify a few lines in CatalogSearch to allow for filtering by a specific attribute instead of product name.
    – NJ.
    Commented Mar 6, 2015 at 0:01
  • It is worth a quick test on your development environment. Besides, what is wrong with the built-in 'advanced search' that comes with Magento? Can you not point your standard search box at that? Commented Mar 6, 2015 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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