stockRepository = $stockRepository; } /** * @inheritdoc */ public function execute(): ResultInterface { $stockId = (int)$this->getRequest()->getParam(StockInterface::STOCK_ID); try { $stock = $this->stockRepository->get($stockId); /** @var Page $result */ $result = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $result->setActiveMenu('Magento_InventoryApi::stock') ->addBreadcrumb(__('Edit Stock'), __('Edit Stock')); $result->getConfig() ->getTitle() ->prepend(__('Edit Stock: %name', ['name' => $stock->getName()])); } catch (NoSuchEntityException $e) { /** @var Redirect $result */ $result = $this->resultRedirectFactory->create(); $this->messageManager->addErrorMessage( __('Stock with id "%value" does not exist.', ['value' => $stockId]) ); $result->setPath('*/*'); } return $result; } }