我正在尝试制作一个列出所有缺货商品的 cms 页面。
protected function _getProductCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection();
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToSort('entity_id', 'desc') //<b>THIS WILL SHOW THE LATEST PRODUCTS FIRST</b>
->addAttributeToFilter('stock_status', 0)
->setPageSize($this->get_prod_count())
->setCurPage($this->get_cur_page());
$this->setProductCollection($collection);
return $collection;
}
但它不起作用。它列出了所有项目。列出所有 qty = 0 或 is_in_stock = 0 的项目的方法是什么?