23 private $stockConfiguration;
28 private $stockRegistry;
38 $this->stockConfiguration = $stockConfiguration;
52 $defaultScopeId = $this->stockConfiguration->getDefaultScopeId();
53 $defaultStockId = $this->stockRegistry->getStock($defaultScopeId)->getStockId();
55 if ($stockId !==
null && $stockId != $defaultStockId) {
58 'The "%1" value is invalid for stock ID. Enter stock with a default value of %2 to try again.',
66 if ($stockItemId !==
null && (!is_numeric($stockItemId) || $stockItemId <= 0)) {
69 'The "%1" value is invalid for stock item ID. ' 70 .
'Enter either zero or a number than zero to try again.',
76 $defaultStockItemId = $this->stockRegistry->getStockItem(
$product->getId())->getItemId();
77 if ($defaultStockItemId && $stockItemId !==
null && $defaultStockItemId != $stockItemId) {
80 'The "%1" value is invalid for stock item ID. ' 81 .
'Use the stock item ID\'s assigned "%2" value and try again.',
__construct(StockConfigurationInterface $stockConfiguration, StockRegistryInterface $stockRegistry)
validate(ProductInterface $product, StockItemInterface $stockItem)