1

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

0

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();

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.