Magento: How to get the product “Minimum Sale Quan

2019-07-27 07:56发布

问题:

Magento 1.7 in the code below I'm trying to get the product attribute "Minimum Qty Allowed in Shopping Cart" to display to the front end. What am I missing? Thanks

<dl class="product-sku">
                    <dt><?php echo $this->__('Product SKU') ?>:</dt>
                    <dd><?php echo $_helper->productAttribute($_product, $_product->getSKU(), 'sku') ?></dd>

                    <dt><?php echo $this->__('Dimensions') ?>:</dt>
                    <dd><?php echo $_helper->productAttribute($_product, $_product->getDimensions(), 'dimensions') ?></dd>

                    <dt><?php echo $this->__('Configuration') ?>:</dt>
                    <dd><?php echo $_helper->productAttribute($_product, $_product->getConfiguration(), 'configuration') ?></dd>

                    <dt><?php echo $this->__('Minimum Purchase Quantity') ?>:</dt>
                    <dd><?php echo $_helper->productAttribute($_product, $_product->getMinSaleQty(), 'min_sale_qty') ?></dd>
                </dl>    

回答1:

This should work:

$productQuantity = Mage::getModel("cataloginventory/stock_item")
->loadByProduct($_product->getId());

And your minimun qty its here....

$productQuantity->getMinSaleQty();


回答2:

A loaded product model contains Mage_CatalogInventory_Model_Stock_Item Object which handles the stock and inventory information. The way I like to handle this is:

$minsale = $_product->getStockItem()->getMinSaleQty();


标签: magento