【发布时间】:2017-06-07 17:49:05
【问题描述】:
如何以编程方式从产品信息中获取缺货状态?
现在产品信息已经准备好为$_product,我们也可以通过此代码获取库存状态。
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
$product_is_stock = $StockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId()); ?>
此外,延期交货功能已解决,因此我们可以将缺货产品添加到购物车中。
【问题讨论】: