Add 'in stock' filter in product collection in magento
To get product that is in stock apply the below filter to your product collection -
$productDetails = Mage::getModel('catalog/category')->load($cat_id)->getProductCollection()->addAttributeToSelect('*');
$productDetails -> addAttributeToFilter('visibility', array('in' => array(4) ));
$productDetails -> addAttributeToFilter('status', array('in' => array(1) ));
$productDetails->joinField('is_in_stock',
'cataloginventory/stock_item',
'is_in_stock',
'product_id=entity_id',
'is_in_stock=1',
'{{table}}.stock_id=1',
'left');
Here we apply three filter - 'visibility' , 'status' , and finally our 'In stock' filter...
0 Comment(s)