Magento Storefront Show Instock Products Only

Define product mould:$_productC = Mage::getResourceModel(’reports/product_collection’);

John code: $_productC->joinField(’inventory_in_stock’, ‘cataloginventory/stock_item’,’is_in_stock’, ‘product_id=entity_id’, ‘{{table}}.is_in_stock=1?);

Example:

$storeId    = Mage::app()->getStore()->getId();
$category = Mage::registry(’current_category’);
$_productC = Mage::getResourceModel(’reports/product_collection’)
->addViewsCount()
->addAttributeToSelect(’*’)
->setStoreId($storeId)
->addStoreFilter($storeId)
->addCategoryFilter($category)
->setPageSize(12)
->setCurPage(1);

Mage::getSingleton(’catalog/product_status’)->addVisibleFilterToCollection($_productC);
Mage::getSingleton(’catalog/product_visibility’)->addVisibleInCatalogFilterToCollection($_productC);
$_productC->joinField(’inventory_in_stock’, ‘cataloginventory/stock_item’,’is_in_stock’, ‘product_id=entity_id’, ‘{{table}}.is_in_stock=1?);
$this->setProductCollection($_productC);



Author:
admin
Tags:
Tags:, , , ,
Category:
Magento
Comments:
You can leave a response, or trackback from your own site.
RSS:
You can follow any responses to this entry through the RSS 2.0 feed.
Navigation:

Comments are closed.