在Magento中添加过滤器

时间:2015-11-11 12:05:23

标签: php magento

如何将此过滤器添加到此代码?  ================================================== ===============

$category_model = Mage::getModel('catalog/category')->load(55); 
$collection = Mage::getResourceModel('catalog/product_collection'); 
$collection->addCategoryFilter($category_model);

我想只显示库存产品,如何使用以下代码Magento

执行此操作

1 个答案:

答案 0 :(得分:0)

它适用于你In Stock Product Collection吗?

回答代码:

$category_model = Mage::getModel('catalog/category')->load(55); 
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addCategoryFilter($category_model);
Mage::getSingleton('cataloginventory/stock')
    ->addInStockFilterToCollection($productCollection);
echo "<pre>";print_r($productCollection->getData());