Magento - 查找库存缺货产品

a1a*_*anm 5 magento

在我的Magento商店中,我有时忘记在向缺货商品添加新库存后从下拉列表中选择"库存".

是否有可能以某种方式获得所有具有库存但标记为"缺货"的产品的清单?

Jos*_*ton 9

If you are able to script something real quick.

$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('is_in_stock', 0)
->addAttributeToFilter('qty', array("gt" => 0));
Run Code Online (Sandbox Code Playgroud)

Sadly I can't seem to remember how to put in the >0 in a way that is supposed to work. Maybe someone can comment on that.

What you can do with $products is run it through a foreach loop and then set the is_in_stock to the value of 1 and you should be in business.

  • 用数组('gt'=> 0)替换"> 0"部分应该有效,所以最终得到 - > addAttributeToFilter('qty',array('gt'=> 0)). (4认同)