stockResource = $stockResource; $this->stockFactory = $stockFactory; } /** * @inheritdoc */ public function execute(int $stockId): StockInterface { /** @var StockInterface $stock */ $stock = $this->stockFactory->create(); $this->stockResource->load($stock, $stockId, StockInterface::STOCK_ID); if (null === $stock->getStockId()) { throw new NoSuchEntityException(__('Stock with id "%value" does not exist.', ['value' => $stockId])); } return $stock; } }