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-catalog
Model
ResourceModel
SetDataToLegacyStockItem.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Model\ResourceModel
;
9
10
use
Magento\CatalogInventory\Api\Data\StockItemInterface
;
11
use
Magento\Framework\App\ResourceConnection
;
12
use
Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface
;
13
17
class
SetDataToLegacyStockItem
18
{
22
private
$resourceConnection;
23
27
private
$getProductIdsBySkus;
28
33
public
function
__construct
(
34
ResourceConnection
$resourceConnection,
35
GetProductIdsBySkusInterface
$getProductIdsBySkus
36
) {
37
$this->resourceConnection =
$resourceConnection
;
38
$this->getProductIdsBySkus = $getProductIdsBySkus;
39
}
40
47
public
function
execute
(
string
$sku,
float
$quantity,
int
$status
)
48
{
49
$productIds
= $this->getProductIdsBySkus->execute([$sku]);
50
51
if
(isset(
$productIds
[$sku])) {
52
$productId
=
$productIds
[$sku];
53
54
$connection
= $this->resourceConnection->getConnection();
55
$connection
->update(
56
$this->resourceConnection->getTableName(
'cataloginventory_stock_item'
),
57
[
58
StockItemInterface::QTY
=> $quantity,
59
StockItemInterface::IS_IN_STOCK
=>
$status
,
60
],
61
[
62
StockItemInterface::PRODUCT_ID
.
' = ?'
=>
$productId
,
63
'website_id = ?'
=> 0,
64
]
65
);
66
}
67
}
68
}
Magento\CatalogInventory\Api\Data\StockItemInterface\PRODUCT_ID
const PRODUCT_ID
Definition:
StockItemInterface.php:24
Magento\InventoryCatalog\Model\ResourceModel\SetDataToLegacyStockItem
Definition:
SetDataToLegacyStockItem.php:17
Magento\CatalogInventory\Api\Data\StockItemInterface
Definition:
StockItemInterface.php:19
Magento\CatalogInventory\Api\Data\StockItemInterface\QTY
const QTY
Definition:
StockItemInterface.php:26
$productId
$productId
Definition:
website_attribute_sync.php:26
Magento\InventoryCatalog\Model\ResourceModel\SetDataToLegacyStockItem\__construct
__construct(ResourceConnection $resourceConnection, GetProductIdsBySkusInterface $getProductIdsBySkus)
Definition:
SetDataToLegacyStockItem.php:33
Magento\CatalogInventory\Api\Data\StockItemInterface\IS_IN_STOCK
const IS_IN_STOCK
Definition:
StockItemInterface.php:54
Magento\InventoryCatalog\Model\ResourceModel\SetDataToLegacyStockItem\execute
execute(string $sku, float $quantity, int $status)
Definition:
SetDataToLegacyStockItem.php:47
Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface
Definition:
GetProductIdsBySkusInterface.php:16
$status
$status
Definition:
order_status.php:8
Magento\InventoryCatalog\Model\ResourceModel
Definition:
AddIsInStockFieldToCollection.php:8
$resourceConnection
$resourceConnection
Definition:
website_attribute_sync.php:32
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
$connection
$connection
Definition:
bulk.php:13
$productIds
$productIds
Definition:
product_with_multiple_options.php:11
Magento\Framework\App\ResourceConnection