magento隐藏库存为0的商品或者status 为 disable 的商品,以及 visibility等于1的商品

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$products = Mage::getModel('catalog/product')->getCollection();
// $products->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
$products->addFieldToFilter('visibility', array('neq'=>Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
$products->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{ {table}}.stock_id=1',
'left')
->addAttributeToFilter('qty', array("gt" => 0));
$products->addAttributeToFilter(
'status',
array('neq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
);

 

坚持原创技术分享,您的支持将鼓励我继续创作!