6 declare(strict_types=1);
15 use Psr\Log\LoggerInterface;
25 private $stockValidator;
30 private $stockResource;
45 LoggerInterface $logger
47 $this->stockValidator = $stockValidator;
48 $this->stockResource = $stockResource;
57 $validationResult = $this->stockValidator->validate(
$stock);
58 if (!$validationResult->isValid()) {
63 $this->stockResource->save(
$stock);
64 return (
int)
$stock->getStockId();
65 }
catch (\Exception $e) {
66 $this->logger->error($e->getMessage());
__construct(StockValidatorInterface $stockValidator, StockResourceModel $stockResource, LoggerInterface $logger)
execute(StockInterface $stock)