Fix: Magento Catalog Search Broken / Not Working

Written by Gordon

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

[php]
$this->getListBlock()
->setCollection($this->_getProductCollection());
[/php]

Modify the line 172

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

to the old code from Version 1.4.1.1

[php]
// Change the previous line to this one
$this->_productCollection = Mage::getSingleton(‘catalogsearch/layer’)->getProductCollection();
[/php]

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

2 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.