How do I get MOQ of bundle products?
-
14-04-2021 - |
Frage
How do I get MOQ of the bundle products? since Bundle product itself doesn't need to set MOQ itself, it depends on the children products. But how do I determine which children MOQ that the bundle is using?
Thanks
Lösung
I was using this to get the MOQ in session
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block Magento\Bundle\Block\Catalog\Product\View\Type\Bundle */ ?>
<?php
$product = $block->getProduct();
$helper = $this->helper('Magento\Catalog\Helper\Output');
$stripSelection = $product->getConfigureMode() ? true : false;
$options = $block->decorateArray($block->getOptions($stripSelection));
$validationRules = [
'required-number' => true,
'validate-item-quantity' => [
'minAllowed' => $product->getStockData()['min_allowed'] ?: 1,
'maxAllowed' => $product->getStockData()['max_allowed'] ?: 1000000,
'qtyIncrements' => $product->getStockData()['qty_increments'] ?: 1,
],
'validate-item-blank-quantity' => [
'minAllowed' => (int)$product->getMinBlankQtyAllowedInCart() ?: 1,
'maxAllowed' => $product->getStockData()['max_allowed'] ?: 1000000,
'qtyIncrements' => (int)$product->getBlankQtyIncrements() ?: 1,
]
];
$_SESSION['validationRules'] = (int)$product->getMinBlankQtyAllowedInCart();
?>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange