0

enter image description here

$productId = $orderItem->getProductId();

2 Answers 2

0

Would something like this work? This should return the notify stock quantity value for the first stock item found for a given product ID.

/**
 * @param StockItemCriteriaInterfaceFactory $stockItemCriteriaFactory
 * @param StockItemRepositoryInterface $stockItemRepository
 */
public function __construct(
    \Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory $stockItemCriteriaFactory,
    \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository
) {
    $this->stockItemCriteriaFactory = $stockItemCriteriaFactory;
    $this->stockItemRepository = $stockItemRepository;
}

/**
 * @param int $productId
 * @return float|null
 */
public function getNotifyStockQtyFromProductId(int $productId): ?float
{
    $criteria = $this->stockItemCriteriaFactory->create();
    $criteria->setProductsFilter($productId);
    $stockItemCollection = $this->stockItemRepository->getList($criteria);
    $stockItems = $stockItemCollection->getItems();

    if (empty($stockItems)) {
        // No stock item found for product.
        return null;
    }

    /** @var \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem */
    $stockItem = reset($stockItems);
    return $stockItem->getNotifyStockQty();
}
0

May be you should know little: Low stock notification alert the merchant that the salable quantity of a stock has reached a critical threshold.

The Notify Quantity fields (Catalog > Products > specific product > Assigned Sources section) override all other settings. The merchant can assign a different threshold for each source for the specific product.

So, the Notify Qty is the API interface method StockConfiguration.php Model as:

$this->stockConfiguration->getNotifyStockQty($this->getStoreId());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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