6 declare(strict_types=1);
26 private $getStockItemConfiguration;
31 private $getStockItemData;
36 private $getReservationsQuantity;
41 private $isSourceItemManagementAllowedForProductType;
46 private $getProductTypesBySkus;
62 $this->getStockItemConfiguration = $getStockItemConfig;
63 $this->getStockItemData = $getStockItemData;
64 $this->getReservationsQuantity = $getReservationsQuantity;
65 $this->isSourceItemManagementAllowedForProductType = $isSourceItemManagementAllowedForProductType;
66 $this->getProductTypesBySkus = $getProductTypesBySkus;
72 public function execute(
string $sku,
int $stockId): float
74 $this->validateProductType($sku);
75 $stockItemData = $this->getStockItemData->execute($sku, $stockId);
80 $stockItemConfig = $this->getStockItemConfiguration->execute($sku, $stockId);
81 $minQty = $stockItemConfig->getMinQty();
84 + $this->getReservationsQuantity->execute($sku, $stockId)
87 return $productQtyInStock;
94 private function validateProductType(
string $sku): void
96 $productType = $this->getProductTypesBySkus->execute([$sku])[$sku];
97 if (
false === $this->isSourceItemManagementAllowedForProductType->execute($productType)) {
99 __(
'Can\'t check requested quantity for products without Source Items support.')
__construct(GetStockItemConfigurationInterface $getStockItemConfig, GetStockItemDataInterface $getStockItemData, GetReservationsQuantityInterface $getReservationsQuantity, IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType, GetProductTypesBySkusInterface $getProductTypesBySkus)
execute(string $sku, int $stockId)