$productId = $orderItem->getProductId();
2 Answers
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();
}
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());