Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-sales
Model
CheckItemsQuantity.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventorySales\Model
;
9
10
use
Magento\Framework\Exception\LocalizedException
;
11
use
Magento\InventorySalesApi\Api\IsProductSalableForRequestedQtyInterface
;
12
use
Magento\InventorySalesApi\Api\Data\ProductSalableResultInterface
;
13
use
Magento\InventorySalesApi\Api\Data\ProductSalabilityErrorInterface
;
14
15
class
CheckItemsQuantity
16
{
20
private
$isProductSalableForRequestedQty;
21
25
public
function
__construct
(
26
IsProductSalableForRequestedQtyInterface
$isProductSalableForRequestedQty
27
) {
28
$this->isProductSalableForRequestedQty = $isProductSalableForRequestedQty;
29
}
30
39
public
function
execute(array
$items
,
int
$stockId) : void
40
{
41
foreach
(
$items
as $sku => $qty) {
43
$isSalable = $this->isProductSalableForRequestedQty->execute((
string
)$sku, $stockId, (
float
)$qty);
44
if
(
false
=== $isSalable->isSalable()) {
45
$errors
= $isSalable->getErrors();
47
$errorMessage = array_pop(
$errors
);
48
throw
new
LocalizedException
(
__
($errorMessage->getMessage()));
49
}
50
}
51
}
52
}
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\InventorySalesApi\Api\IsProductSalableForRequestedQtyInterface
Definition:
IsProductSalableForRequestedQtyInterface.php:15
Magento\InventorySalesApi\Api\Data\ProductSalableResultInterface
Definition:
ProductSalableResultInterface.php:15
__
__()
Definition:
__.php:13
Magento\InventorySalesApi\Api\Data\ProductSalabilityErrorInterface
Definition:
ProductSalabilityErrorInterface.php:13
Magento\InventorySales\Model\CheckItemsQuantity
Definition:
CheckItemsQuantity.php:15
Magento\InventorySales\Model\CheckItemsQuantity\__construct
__construct(IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty)
Definition:
CheckItemsQuantity.php:25
Magento\InventorySales\Model
Definition:
CheckItemsQuantity.php:8
$errors
$errors
Definition:
overview.phtml:9
$items
$items
Definition:
order_rollback.php:21