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-low-quantity-notification
Setup
Patch
Data
MigrateCatalogInventoryNotifyStockQuantityData.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryLowQuantityNotification\Setup\Patch\Data
;
9
10
use
Magento\CatalogInventory\Model\Stock\Item
as StockItem;
11
use
Magento\Framework\Setup\ModuleDataSetupInterface
;
12
use
Magento\Framework\Setup\Patch\DataPatchInterface
;
13
use
Magento\Inventory\Model\ResourceModel\SourceItem
;
14
use
Magento\InventoryApi\Api\Data\SourceItemInterface
;
15
use
Magento\InventoryCatalogApi\Api\DefaultSourceProviderInterface
;
16
20
class
MigrateCatalogInventoryNotifyStockQuantityData
implements
DataPatchInterface
21
{
25
private
$moduleDataSetup;
26
30
private
$defaultSourceProvider;
31
36
public
function
__construct
(
37
ModuleDataSetupInterface
$moduleDataSetup,
38
DefaultSourceProviderInterface
$defaultSourceProvider
39
) {
40
$this->moduleDataSetup = $moduleDataSetup;
41
$this->defaultSourceProvider =
$defaultSourceProvider
;
42
}
43
47
public
function
apply
()
48
{
49
$defaultSource = $this->defaultSourceProvider->getCode();
50
$connection
= $this->moduleDataSetup->getConnection();
51
$select
=
$connection
->select();
52
$select
53
->from(
54
[
'stock_item'
=> $this->moduleDataSetup->getTable(StockItem::ENTITY)],
55
[
56
'source_item.'
.
SourceItemInterface::SOURCE_CODE
,
57
'source_item.'
.
SourceItemInterface::SKU
,
58
'stock_item.notify_stock_qty'
,
59
]
60
)->join(
61
[
'product'
=> $this->moduleDataSetup->getTable(
'catalog_product_entity'
)],
62
'product.entity_id = stock_item.product_id'
,
63
[]
64
)->join(
65
[
'source_item'
=> $this->moduleDataSetup->getTable(
SourceItem::TABLE_NAME_SOURCE_ITEM
)],
66
'source_item.sku = product.sku'
,
67
[]
68
)->where(
69
'stock_item.use_config_notify_stock_qty = 0'
70
)->where(
71
'source_item.'
.
SourceItemInterface::SOURCE_CODE
.
' = ?'
,
72
$defaultSource
73
);
74
75
$sql =
$connection
->insertFromSelect(
76
$select
,
77
$this->moduleDataSetup->getTable(
'inventory_low_stock_notification_configuration'
)
78
);
79
80
$connection
->query($sql);
81
82
return
$this;
83
}
84
88
public
static
function
getDependencies
()
89
{
90
return
[];
91
}
92
96
public
function
getAliases
()
97
{
98
return
[];
99
}
100
}
Magento\InventoryLowQuantityNotification\Setup\Patch\Data\MigrateCatalogInventoryNotifyStockQuantityData\__construct
__construct(ModuleDataSetupInterface $moduleDataSetup, DefaultSourceProviderInterface $defaultSourceProvider)
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:36
Magento\InventoryLowQuantityNotification\Setup\Patch\Data\MigrateCatalogInventoryNotifyStockQuantityData\getDependencies
static getDependencies()
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:88
Magento\InventoryLowQuantityNotification\Setup\Patch\Data\MigrateCatalogInventoryNotifyStockQuantityData\getAliases
getAliases()
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:96
Magento\CatalogInventory\Model\Stock\Item
Definition:
Item.php:23
Magento\Framework\Setup\Patch\DataPatchInterface
Definition:
DataPatchInterface.php:12
Magento\InventoryLowQuantityNotification\Setup\Patch\Data\MigrateCatalogInventoryNotifyStockQuantityData\apply
apply()
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:47
Magento\InventoryLowQuantityNotification\Setup\Patch\Data
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:8
Magento\InventoryApi\Api\Data\SourceItemInterface\SOURCE_CODE
const SOURCE_CODE
Definition:
SourceItemInterface.php:26
$defaultSourceProvider
$defaultSourceProvider
Definition:
source_items_on_default_source.php:22
Magento\InventoryApi\Api\Data\SourceItemInterface
Definition:
SourceItemInterface.php:20
Magento\Framework\Setup\ModuleDataSetupInterface
Definition:
ModuleDataSetupInterface.php:14
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
Magento\InventoryCatalogApi\Api\DefaultSourceProviderInterface
Definition:
DefaultSourceProviderInterface.php:15
Magento\InventoryApi\Api\Data\SourceItemInterface\SKU
const SKU
Definition:
SourceItemInterface.php:25
Magento\Inventory\Model\ResourceModel\SourceItem\TABLE_NAME_SOURCE_ITEM
const TABLE_NAME_SOURCE_ITEM
Definition:
SourceItem.php:20
Magento\Inventory\Model\ResourceModel\SourceItem
Definition:
Collection.php:8
$connection
$connection
Definition:
bulk.php:13
Magento\InventoryLowQuantityNotification\Setup\Patch\Data\MigrateCatalogInventoryNotifyStockQuantityData
Definition:
MigrateCatalogInventoryNotifyStockQuantityData.php:20