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
CleanupReservations.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\CleanupReservationsInterface
;
13
17
class
CleanupReservations
implements
CleanupReservationsInterface
18
{
22
private
$resource;
23
27
private
$groupConcatMaxLen;
28
33
public
function
__construct
(
34
ResourceConnection
$resource,
35
int
$groupConcatMaxLen
36
) {
37
$this->resource =
$resource
;
38
$this->groupConcatMaxLen = $groupConcatMaxLen;
39
}
40
44
public
function
execute
(): void
45
{
46
$connection
= $this->resource->getConnection();
47
$reservationTable = $this->resource->getTableName(
'inventory_reservation'
);
48
49
$select
=
$connection
->select()
50
->from(
51
$reservationTable,
52
[
'GROUP_CONCAT('
.
ReservationInterface::RESERVATION_ID
.
')'
]
53
)
54
->group([
ReservationInterface::STOCK_ID
,
ReservationInterface::SKU
])
55
->having(
'SUM('
.
ReservationInterface::QUANTITY
.
') = 0'
);
56
$connection
->query(
'SET group_concat_max_len = '
. $this->groupConcatMaxLen);
57
$groupedReservationIds = implode(
','
,
$connection
->fetchCol(
$select
));
58
59
$condition = [
ReservationInterface::RESERVATION_ID
.
' IN (?)'
=> explode(
','
, $groupedReservationIds)];
60
$connection
->delete($reservationTable, $condition);
61
}
62
}
Magento\InventoryReservationsApi\Model\ReservationInterface
Definition:
ReservationInterface.php:18
Magento\InventoryReservationsApi\Model\ReservationInterface\RESERVATION_ID
const RESERVATION_ID
Definition:
ReservationInterface.php:23
Magento\InventoryReservations\Model\ResourceModel\CleanupReservations
Definition:
CleanupReservations.php:17
Magento\InventoryReservations\Model\ResourceModel
Definition:
CleanupReservations.php:8
Magento\InventoryReservationsApi\Model\ReservationInterface\QUANTITY
const QUANTITY
Definition:
ReservationInterface.php:26
$resource
$resource
Definition:
bulk.php:12
Magento\InventoryReservations\Model\ResourceModel\CleanupReservations\__construct
__construct(ResourceConnection $resource, int $groupConcatMaxLen)
Definition:
CleanupReservations.php:33
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
Magento\InventoryReservationsApi\Model\CleanupReservationsInterface
Definition:
CleanupReservationsInterface.php:16
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\InventoryReservations\Model\ResourceModel\CleanupReservations\execute
execute()
Definition:
CleanupReservations.php:44
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
$connection
$connection
Definition:
bulk.php:13
Magento\Framework\App\ResourceConnection