6 declare(strict_types=1);
25 private $getLegacyStockItem;
30 private $stockItemConfigurationFactory;
35 private $isProductAssignedToStock;
40 private $defaultStockProvider;
45 private $isSourceItemManagementAllowedForSku;
56 StockItemConfigurationFactory $stockItemConfigurationFactory,
61 $this->getLegacyStockItem = $getLegacyStockItem;
62 $this->stockItemConfigurationFactory = $stockItemConfigurationFactory;
63 $this->isProductAssignedToStock = $isProductAssignedToStock;
64 $this->defaultStockProvider = $defaultStockProvider;
65 $this->isSourceItemManagementAllowedForSku = $isSourceItemManagementAllowedForSku;
73 if ($this->defaultStockProvider->getId() !== $stockId
74 &&
true === $this->isSourceItemManagementAllowedForSku->execute($sku)
75 &&
false === $this->isProductAssignedToStock->execute($sku, $stockId)) {
77 __(
'The requested sku is not assigned to given stock.')
81 return $this->stockItemConfigurationFactory->create(
83 'stockItem' => $this->getLegacyStockItem->execute($sku)
__construct(GetLegacyStockItem $getLegacyStockItem, StockItemConfigurationFactory $stockItemConfigurationFactory, IsProductAssignedToStockInterface $isProductAssignedToStock, DefaultStockProviderInterface $defaultStockProvider, IsSourceItemManagementAllowedForSkuInterface $isSourceItemManagementAllowedForSku)
execute(string $sku, int $stockId)