6 declare(strict_types=1);
31 private $stockRepository;
41 parent::__construct($context);
50 $resultRedirect = $this->resultRedirectFactory->create();
53 if ($stockId ===
null) {
54 $this->messageManager->addErrorMessage(
__(
'Wrong request.'));
55 return $resultRedirect->setPath(
'*/*');
59 $stockId = (int)$stockId;
60 $this->stockRepository->deleteById($stockId);
61 $this->messageManager->addSuccessMessage(
__(
'The Stock has been deleted.'));
62 $resultRedirect->setPath(
'*/*');
64 $this->messageManager->addErrorMessage($e->getMessage());
65 $resultRedirect->setPath(
'*/*/edit', [
71 return $resultRedirect;
__construct(Context $context, StockRepositoryInterface $stockRepository)