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-indexer
Plugin
InventoryApi
InvalidateAfterEnablingOrDisablingSourcePlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryIndexer\Plugin\InventoryApi
;
9
10
use
Magento\Framework\Indexer\IndexerRegistry
;
11
use
Magento\InventoryApi\Api\Data\SourceInterface
;
12
use
Magento\InventoryApi\Api\SourceRepositoryInterface
;
13
use
Magento\InventoryIndexer\Indexer\InventoryIndexer
;
14
use
Magento\InventoryIndexer\Model\ResourceModel\IsInvalidationRequiredForSource
;
15
19
class
InvalidateAfterEnablingOrDisablingSourcePlugin
20
{
24
private
$indexerRegistry;
25
29
private
$isInvalidationRequiredForSource;
30
35
public
function
__construct
(
36
IndexerRegistry
$indexerRegistry,
37
IsInvalidationRequiredForSource
$isInvalidationRequiredForSource
38
) {
39
$this->indexerRegistry =
$indexerRegistry
;
40
$this->isInvalidationRequiredForSource = $isInvalidationRequiredForSource;
41
}
42
52
public
function
aroundSave
(
53
SourceRepositoryInterface
$subject,
54
callable $proceed,
55
SourceInterface
$source
56
) {
57
$invalidationRequired =
false
;
58
if
(
$source
->getSourceCode()) {
59
$invalidationRequired = $this->isInvalidationRequiredForSource->execute(
60
$source
->getSourceCode(),
61
(bool)
$source
->isEnabled()
62
);
63
}
64
65
$proceed(
$source
);
66
67
if
($invalidationRequired) {
68
$indexer
= $this->indexerRegistry->get(
InventoryIndexer::INDEXER_ID
);
69
if
(
$indexer
->isValid()) {
70
$indexer
->invalidate();
71
}
72
}
73
}
74
}
Magento\InventoryIndexer\Model\ResourceModel\IsInvalidationRequiredForSource
Definition:
IsInvalidationRequiredForSource.php:19
$source
$source
Definition:
source.php:23
Magento\InventoryIndexer\Plugin\InventoryApi\InvalidateAfterEnablingOrDisablingSourcePlugin\aroundSave
aroundSave(SourceRepositoryInterface $subject, callable $proceed, SourceInterface $source)
Definition:
InvalidateAfterEnablingOrDisablingSourcePlugin.php:52
Magento\InventoryIndexer\Plugin\InventoryApi\InvalidateAfterEnablingOrDisablingSourcePlugin\__construct
__construct(IndexerRegistry $indexerRegistry, IsInvalidationRequiredForSource $isInvalidationRequiredForSource)
Definition:
InvalidateAfterEnablingOrDisablingSourcePlugin.php:35
$indexerRegistry
$indexerRegistry
Definition:
product_different_store_prices.php:20
Magento\InventoryIndexer\Plugin\InventoryApi
Definition:
InvalidateAfterEnablingOrDisablingSourcePlugin.php:8
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
Magento\InventoryApi\Api\SourceRepositoryInterface
Definition:
SourceRepositoryInterface.php:29
Magento\Framework\Indexer\IndexerRegistry
Definition:
IndexerRegistry.php:12
Magento\InventoryIndexer\Indexer\InventoryIndexer
Definition:
InventoryIndexer.php:18
Magento\InventoryIndexer\Indexer\InventoryIndexer\INDEXER_ID
const INDEXER_ID
Definition:
InventoryIndexer.php:23
Magento\InventoryIndexer\Plugin\InventoryApi\InvalidateAfterEnablingOrDisablingSourcePlugin
Definition:
InvalidateAfterEnablingOrDisablingSourcePlugin.php:19
$indexer
$indexer
Definition:
product_different_store_prices.php:21