SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH
Google Quality Score
Google Quality Score

Get Qty Increments value by product SKU, Id Magento 2.

In Magento 2, a very nice function can customize the number of increments when buying products. Get value Increment product quantity programmatically by product id or SKU in Magento.

Qty Increments Value will be set from the Admin Panel and add qty to multiply that value. If you have a set value equals to 2, You must add a multiple of 2 in the qty field to add a product. (Allowed Value 2, 4, 6, 8, etc…).

Go To Catalog -> Products -> Add/Edit Product,
Click on Advanced Inventory,
Select Options as Yes from the Enable Qty Increments dropdown and a new input field will be visible.
Now, Set Qty Increments Value as per your choice.
Save Product.

Step 1: Declare the command to get product stock information

You will use a block class of the module Magepow_QtyIncrement, then possibly inject the object of \Magento\CatalogInventory\Model\Stock\StockItemRepository class in the constructor of the module’s block class.

app/code/Magepow/QtyIncrement/Block/QtyIncrement.php

<?php
namespace Magepow\QtyIncrement\Block;
class QtyIncrement extends \Magento\Framework\View\Element\Template
{    
    protected $_stockItemRepository;
        
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,        
        \Magento\CatalogInventory\Model\Stock\StockItemRepository $stockItemRepository,
        array $data = []
    )
    {
        $this->_stockItemRepository = $stockItemRepository;
        parent::__construct($context, $data);
    }
    
    public function getStockItem($productId)
    {
        return $this->_stockItemRepository->get($productId);
    }
}
?>

Step 2: Load product id and sku in template file

Call method with the required parameter.

$id = '13';
$qtyIncrement = $this->getQtyIncrements($id);

If the Product has set qty increment value, it will display the qty increment value in the output with an integer type otherwise return as null.

We can get qty increment by object Manager

<?php 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $item_load = $objectManager->create('Magento\Catalog\Model\Product')->load($_product->getId());
    $qtyIncrements = $item_load->getExtensionAttributes()->getStockItem()->getQtyIncrements();
?>

Hope this article will help you in some way, You can see useful articles in the next articles.

Anything you need support from Magento 2 feels free to contact us at Alothemes and

Phone: (+84)865633728

Email: support@alothemes.com