[Magento] Default Search / Mini Search returns 0 results

Was debugging this weird problem with a client's Magento 1.5.1.0 site.

The Mini Search (and the default search - http://example.com/catalogsearch/result/?q=searchTerm) is not returning the correct result.

Surprisingly the advanced search is working fine.

After trying out all sort of methods, finding and editing the .phtml, .xml files. I found out that its one of the core files that causes this issue.

Solution

Open up app/code/core/Mage/CatalogSearch/Block/Result.php

Uncomment line 149 and 150
//        $this->getListBlock()
//           ->setCollection($this->_getProductCollection());


Then change line 172
$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();
to
$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();

That solves the search problem.

:)

Comments

  1. Awesome! Searched everywhere for a solution and this worked perfectly. Thanks so much!

    ReplyDelete
  2. Thank you. You have saved my life (well, more or less ;-) )
    Searched for a solution so long, finally found this. Works perfectly.
    Great Deal! :D

    ReplyDelete
  3. A quick thanks from me too. The change worked perfectly.

    ReplyDelete
  4. Sorry, Your given solution is not working for me. I am using magento1.7 kindly provide some more solutions.

    ReplyDelete
  5. You are a life saver.... millions thankssss

    ReplyDelete

Post a Comment

Popular posts from this blog

[Azure Websites PHP] Cross Domain request results in blank response page after Preflight HTTP OPTIONS

[Magento] Create Contact Form with Dynamic Recipient