Fix: Magento Catalog Search Broken / Not Working

Written by Sid Vel

Topics: Magento

We recently updated a Magento install from 1.3.2.4 to 1.5.1.0. Everything worked fine, expect the search function. Whatever we searched for, the site returned just one result. This seems to be a problem with upgrades and even some fresh installs of Magneto 1.4.1.1, 1.4.2, 1.5.1.0, etc. The following is the fix. This will require fixing the core files. Hopefully the Magento team will address the issue in the next update.

Edit app/code/core/Mage/CatalogSearch/Block/Result.php

Uncomment lines 149 and 150

$this->getListBlock()
->setCollection($this->_getProductCollection());

Modify the line 172

// Change this line
$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();

to the old code from Version 1.4.1.1

// Change the previous line to this one
$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();

Once the code is fixed, go to the Admin panel (System > Index Management) and select all the Indexes > Pick action is “Reindex data” > Press “Submit”.

The search should work now.

Source

17 Comments Comments For This Post I'd Love to Hear Yours!

  1. mark says:

    thank you very much, i had a new install 1.5.1.0 magento and this worked PERFECTLY!!!

    Easy fix and very much needed..

  2. Matthew says:

    Thank you, did the trick. In our case 1.5.1 was not even “searching/filtering” the catalog of products for the search term and just returned everything visible.

  3. Jo says:

    Thanks so much – it worked like a dream!

    It totally fixed the issue I was having whereby a search was not filtering any products, instead it was delivering everything. My search is now back to normal and working perfectly!

  4. Matt W says:

    Thanks a ton! This really saved me…

    • Matt W says:

      Had this working, but then 1 1/2 days to 2 days later, the search stopped working again. I am again getting no results returned, and I didn’t change a thing after making the edits you suggested. Has anyone else had this problem? Can you please help shed some light on this?

      Running Magento 1.5.1 on Apache server. All DB tables pertaining to catalogsearch are still in order, and tables are filled with data.

      • Sid Vel says:

        Did you try reindexing? System > Index Management. Magento should refresh indexes on a regular basis. It can fail some time. Reindexing will always make it work, but it can fail again. Can you give a link to your website?

  5. Sunil says:

    Thanks a ton… i just can tell you how much help this is for me. I was trying to solve this for 2 days..

    Thanks a lot again

  6. Rico says:

    Thank you very much for this fix. Saved my day :)

  7. DM says:

    Worked! On my 1.5.0.1 install, I was getting ALL products returned with any search term. This worked to narrow down the results.

  8. ARandomDeveloper says:

    THIS FIX WORKS (Tried and tested on Magento Version 1.6.1.0)!!

    I have searched for hours trying to find a simple fix without editing code, but many websites led me back to this single fix.

    THIS WORKS

    PLEASE DON’T BE AFRAID TO TRY IT! IT’S NOT HARD AT ALL!

    THANK YOU SO MUCH!

  9. taulant says:

    thank you so much! I spent two hours trying to figure this out until I ran into your blog post. This fixed my problem. Version 1.5.1.0

  10. Dr. Gasket says:

    Hello,
    I am using 1.6 and search box does not find all products or none.
    i did all changes of uncomment and etc. re-index and compile…but still no results.
    for example i have 50 products under the brand Hobart. when you search Hobart you get only 1 results.
    all my products are set to be found in catalog and search

    what might be the problem ?

    Thank you

    public function setListCollection()
    {
    $this->getListBlock()
    ->setCollection($this->_getProductCollection());
    return $this;
    }

    /**
    * Retrieve Search result list HTML output
    *
    * @return string
    */
    public function getProductListHtml()
    {
    return $this->getChildHtml(‘search_result_list’);
    }

    /**
    * Retrieve loaded category collection
    *
    * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
    */
    protected function _getProductCollection()
    {
    if (is_null($this->_productCollection)) {
    $this->_productCollection = Mage::getSingleton(‘catalogsearch/layer’)->getProductCollection();
    }

  11. Paul Doherty says:

    Worked like a charm on 1.6!!! Thanks.

  12. Thank you very very much. I have a theme updated to 1.6.2 and it crashed this way. Yours tips works perfectly and save me a lot of time.

  13. But doesnt work after upgrade from 1.6.2 to 1.7.0 (stable). =/

  14. sorry, my mistake. also works for 1.7.0. :P

17 Comments Trackbacks For This Post

  1. Magento 1.5 quick search returns all the products or unexpected result – a discussion and collected solutions | LAMP stuffs you look for
  2. Magento 1.5 quick search returns all the products or unexpected result – a discussion and collected solutions | Experience Explored
  3. Magento 1.5 quick search returns all the products or unexpected result – a discussion and collected solutions | Experience Explored

Leave a Comment Here's Your Chance to Be Heard!