I have the situation to filter product who is having Stock Availability
as 'out of stock
' in product listing page. Need to show only in product detail page. I tried with following event in my custom module
<events>
<catalog_block_product_list_collection>
<observers>
<test_instockonly_list>
<type>singleton</type>
<class>test/observer</class>
<method>addInStockOnlyFilter</method>
</test_instockonly_list>
</observers>
</catalog_block_product_list_collection>
</events>
and method 'addInStockOnlyFilter' in observer filter to add additional query to filter out of stock item
/**
* Observes the catalog_block_product_list_collection event
*/
public function addInStockOnlyFilter($observer){
$observer->getEvent()->getCollection()
->joinField('stock_status','cataloginventory/stock_status','stock_status',
'product_id=entity_id', array(
'stock_status' => Mage_CatalogInventory_Model_Stock_Status::STATUS_IN_STOCK,
'website_id' => Mage::app()->getWebsite()->getWebsiteId(),
))
;
}
After clear cache and run the listing page. Still i can see out of stock item from product detail page.
What was i missed here. Kindly advice