After upgrading from 1.4 to 1.5 the quick search returns all products. The advanced search works just fine. I've cleared the cache and re-indexed everything but still nothing. Any ideas why?
The search also doesn't apply the minimum query length set in the admin (ie, I can enter nothing and still be shown everything). Switching between LIKE or FULLTEXT search seems to do nothing.
I've seen this Magento Search returns All Products but all my plugins are up to date (and I don't have any search plugins).
I wrestled for this for days, it turns out the catalogsearch/layer block is what eventually calls into the search engine and stores the results in the catalogsearch_results table.
The search results list block is just a simple query over the products collection joined with the catalogsearch_results table on the product_id column (and the LIKE or FULLTEXT filter).
So, in short in one of your layout XML files (or your local.xml) make sure you have this code:
<catalogsearch_result_index>
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" template="catalog/layer/view.phtml"/>
</reference>
</catalogsearch_result_index>
Of course you can put it in any other block (not just left) but make sure it is referenced somewhere in the handle before the catalogsearch/result block (which is aliased "search.result" in the XML).
If you removed layer navigation by using the remove tag, you'll have to use a different name for the block (instead of "catalogsearch.leftnav").
If you need to hide it even from the search results page, keep it referenced in the XML but hide it with CSS:
.block-layered-nav {
display: none;
}
I hope this helps some other poor soul tortured by this design pattern abomination.
I fixed the problem by edit the app/code/core/Mage/CatalogSearch/Block Result.php
Uncomment the line 149 and 150
$this->getListBlock()
->setCollection($this->_getProductCollection());
And change line 172 from:
$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();
to:
$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
Are you using a 2-column layout with layered search results ... catalog/layer/view.phtml ? I noticed on when I switched to a 1-column layout and removed the layered navigation that the results returned all products not matching results to my search query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With