Man*_*ani 3 magento magento-1.9
这是我的产品系列,任何人都可以帮助我从产品系列中获取库存状态。
$collection = Mage::getModel('catalog/category')
->load($categoryId)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG));
return $collection;
Run Code Online (Sandbox Code Playgroud)
库存状态 ( is_in_stock) 是每个产品系列的一部分。
foreach ($collections as $product) {
echo $product->getStockItem()->getIsInStock();
}
Run Code Online (Sandbox Code Playgroud)
1如果有货,则返回,否则返回null。
如果您需要其他股票信息,min_qty或者backorders您可以将其添加到您的收藏中:
$collection->setFlag('require_stock_items', true);
Run Code Online (Sandbox Code Playgroud)
更多详情:https : //magento.stackexchange.com/questions/106455/get-product-stock-quantity-in-magento/209510#209510