Quote item quantity validator.
@api
- Since
- 100.0.2 @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- Deprecated:
- 2.3.0 Replaced with Multi Source Inventory https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html
Definition at line 33 of file QuantityValidator.php.
◆ __construct()
- Parameters
-
Option | $optionInitializer | |
StockItem | $stockItemInitializer | |
StockRegistryInterface | $stockRegistry | |
StockStateInterface | $stockState | |
- Returns
- void
Definition at line 62 of file QuantityValidator.php.
◆ _removeErrorsFromQuoteAndItem()
_removeErrorsFromQuoteAndItem |
( |
|
$item, |
|
|
|
$code |
|
) |
| |
|
protected |
Removes error statuses from quote and item, set by this observer
- Parameters
-
- Returns
- void
Definition at line 258 of file QuantityValidator.php.
260 if (
$item->getHasError()) {
261 $params = [
'origin' =>
'cataloginventory',
'code' =>
$code];
266 if (
$quote->getHasError()) {
267 $quoteItems =
$quote->getItemsCollection();
268 $canRemoveErrorFromQuote =
true;
275 foreach ($errorInfos as $errorInfo) {
276 if ($errorInfo[
'code'] ==
$code) {
277 $canRemoveErrorFromQuote =
false;
282 if (!$canRemoveErrorFromQuote) {
287 if ($canRemoveErrorFromQuote) {
288 $params = [
'origin' =>
'cataloginventory',
'code' =>
$code];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ validate()
Check product inventory data when quote item quantity declaring
- Parameters
-
\Magento\Framework\Event\Observer | $observer | |
- Returns
- void
- Exceptions
-
Check if product in stock. For composite products check base (parent) item stock status
Check item for options
Definition at line 108 of file QuantityValidator.php.
123 if (!
$stockItem instanceof StockItemInterface) {
124 throw new LocalizedException(
__(
'The Product stock item is invalid. Verify the stock item and try again.'));
135 if (
$quoteItem->getQuote()->getIsSuperMode()) {
140 $stockStatus = $this->stockRegistry->getStockStatus(
$product->getId(),
$product->getStore()->getWebsiteId());
143 $parentStockStatus =
false;
150 $parentStockStatus = $this->stockRegistry->getStockStatus(
152 $product->getStore()->getWebsiteId()
163 __(
'This product is out of stock.')
169 __(
'Some of the products are out of stock.')
195 $removeError =
false;
_removeErrorsFromQuoteAndItem($item, $code)
◆ $optionInitializer
◆ $stockItemInitializer
◆ $stockRegistry
◆ $stockState
The documentation for this class was generated from the following file: