如何将此过滤器添加到此代码? ================================================== ===============
$category_model = Mage::getModel('catalog/category')->load(55);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addCategoryFilter($category_model);
我想只显示库存产品,如何使用以下代码Magento
执行此操作答案 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());