Get Qty Increments value by product SKU Magento 2.

Get Product Qty Increments value programmatically by product id or SKU in Magento.

Qty Increments Value will be set from the Admin Panel and used to add qty in multiply of that value. If you have set value equals 5, You must have to add multiple of 5 in qty field to add a product. (Allowed Value 5, 10, 15, 20, 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.

<?php
namespace Jesadiya\QtyIncrement\Model;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Psr\Log\LoggerInterface;

class Data
{
    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @var ProductRepositoryInterface
     */
    private $productRepository;

    public function __construct(
        LoggerInterface $logger,
        ProductRepositoryInterface $productRepository,
    ) {
        $this->logger = $logger;
        $this->productRepository = $productRepository;
    }

    /**
     * get Qty Increments value of product
     *
     * @param string $sku
     * @return int|null
     */
    public function getQtyIncrements(string $sku)
    {
        $qtyIncrement = null;
        try {
            $product = $this->productRepository->get($sku);
            $qtyIncrement = (int)$product->getExtensionAttributes()->getStockItem()->getQtyIncrements();
        } catch (Exception $exception) {
            $this->logger->error($exception->getMessage());
        }
        return $qtyIncrement;
    }
}

Call method with the required parameter,

$sku = '24-MB01';
$qtyIncrement = $this->getQtyIncrements($sku);

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.