magento - Hide out of stock products only in search result pages -


we can hide out of stock products in categories , catalog search through : system > configuration > catalog > inventory > display out of stock products

yet, how can hide products in search results ?

you override _getsearchableproducts function in class mage_catalogsearch_model_resource_fulltext searches in-stock products.

file modify: app/code/core/mage/catalogsearch/model/resource/fulltext.php

/**  * retrieve searchable products per store  *  * @param int $storeid  * @param array $staticfields  * @param array|int $productids  * @param int $lastproductid  * @param int $limit  * @return array  */ protected function _getsearchableproducts($storeid, array $staticfields, $productids = null, $lastproductid = 0, $limit = 100) {             ...      ->join(         array('stock_status' => $this->gettable('cataloginventory/stock_status')),         $writeadapter->quoteinto(             'stock_status.product_id=e.entity_id , stock_status.stock_status = 1 , stock_status.website_id=?', // add stock_status = 1 condition             $websiteid         ),         array('in_stock' => 'stock_status')     );      .... } 

remember reindex "catalog search index" afterwards.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -