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-reservations
Model
ResourceModel
GetReservationsQuantity.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryReservations\Model\ResourceModel
;
9
10
use
Magento\Framework\App\ResourceConnection
;
11
use
Magento\InventoryReservationsApi\Model\ReservationInterface
;
12
use
Magento\InventoryReservationsApi\Model\GetReservationsQuantityInterface
;
13
17
class
GetReservationsQuantity
implements
GetReservationsQuantityInterface
18
{
22
private
$resource;
23
27
public
function
__construct
(
28
ResourceConnection
$resource
29
) {
30
$this->resource =
$resource
;
31
}
32
36
public
function
execute
(
string
$sku,
int
$stockId): float
37
{
38
$connection
= $this->resource->getConnection();
39
$reservationTable = $this->resource->getTableName(
'inventory_reservation'
);
40
41
$select
=
$connection
->select()
42
->from($reservationTable, [
ReservationInterface::QUANTITY
=>
'SUM('
.
ReservationInterface::QUANTITY
.
')'
])
43
->where(
ReservationInterface::SKU
.
' = ?'
, $sku)
44
->where(
ReservationInterface::STOCK_ID
.
' = ?'
, $stockId)
45
->limit(1);
46
47
$reservationQty =
$connection
->fetchOne(
$select
);
48
if
(
false
=== $reservationQty) {
49
$reservationQty = 0;
50
}
51
return
(
float
)$reservationQty;
52
}
53
}
Magento\InventoryReservationsApi\Model\ReservationInterface
Definition:
ReservationInterface.php:18
Magento\InventoryReservations\Model\ResourceModel
Definition:
CleanupReservations.php:8
Magento\InventoryReservationsApi\Model\ReservationInterface\QUANTITY
const QUANTITY
Definition:
ReservationInterface.php:26
Magento\InventoryReservations\Model\ResourceModel\GetReservationsQuantity
Definition:
GetReservationsQuantity.php:17
$resource
$resource
Definition:
bulk.php:12
Magento\InventoryReservations\Model\ResourceModel\GetReservationsQuantity\__construct
__construct(ResourceConnection $resource)
Definition:
GetReservationsQuantity.php:27
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
Magento\InventoryReservationsApi\Model\GetReservationsQuantityInterface
Definition:
GetReservationsQuantityInterface.php:15
Magento\InventoryReservationsApi\Model\ReservationInterface\STOCK_ID
const STOCK_ID
Definition:
ReservationInterface.php:24
Magento\InventoryReservationsApi\Model\ReservationInterface\SKU
const SKU
Definition:
ReservationInterface.php:25
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
$connection
$connection
Definition:
bulk.php:13
Magento\Framework\App\ResourceConnection
Magento\InventoryReservations\Model\ResourceModel\GetReservationsQuantity\execute
execute(string $sku, int $stockId)
Definition:
GetReservationsQuantity.php:36