-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from magento-engcom/delete_source_items_stock…
…_items_synchronization Synchronization between sourceItem and stockItem deletion for defaultSourceId
- Loading branch information
Showing
23 changed files
with
1,073 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/code/Magento/InventoryCatalog/Model/ResourceModel/SetDataToLegacyStockItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryCatalog\Model\ResourceModel; | ||
|
||
use Magento\CatalogInventory\Api\Data\StockItemInterface; | ||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\InventoryCatalog\Model\GetProductIdsBySkusInterface; | ||
|
||
/** | ||
* Set data to legacy catalocinventory_stock_item table via plain MySql query | ||
*/ | ||
class SetDataToLegacyStockItem | ||
{ | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
/** | ||
* @var GetProductIdsBySkusInterface | ||
*/ | ||
private $getProductIdsBySkus; | ||
|
||
/** | ||
* @param ResourceConnection $resourceConnection | ||
* @param GetProductIdsBySkusInterface $getProductIdsBySkus | ||
*/ | ||
public function __construct( | ||
ResourceConnection $resourceConnection, | ||
GetProductIdsBySkusInterface $getProductIdsBySkus | ||
) { | ||
$this->resourceConnection = $resourceConnection; | ||
$this->getProductIdsBySkus = $getProductIdsBySkus; | ||
} | ||
|
||
/** | ||
* @param string $sku | ||
* @param float $quantity | ||
* @param int $status | ||
* @return void | ||
*/ | ||
public function execute(string $sku, float $quantity, int $status) | ||
{ | ||
$productId = $this->getProductIdsBySkus->execute([$sku])[$sku]; | ||
|
||
$connection = $this->resourceConnection->getConnection(); | ||
$connection->update( | ||
$this->resourceConnection->getTableName('cataloginventory_stock_item'), | ||
[ | ||
StockItemInterface::IS_IN_STOCK => $status, | ||
StockItemInterface::QTY => $quantity, | ||
], | ||
[ | ||
StockItemInterface::PRODUCT_ID . ' = ?' => $productId, | ||
'website_id = ?' => 0, | ||
] | ||
); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
app/code/Magento/InventoryCatalog/Model/ResourceModel/SetDataToLegacyStockStatus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryCatalog\Model\ResourceModel; | ||
|
||
use Magento\CatalogInventory\Api\Data\StockStatusInterface; | ||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\InventoryCatalog\Model\GetProductIdsBySkusInterface; | ||
|
||
/** | ||
* Set data to legacy cataloginventory_stock_status table via plain MySql query | ||
*/ | ||
class SetDataToLegacyStockStatus | ||
{ | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
/** | ||
* @var GetProductIdsBySkusInterface | ||
*/ | ||
private $getProductIdsBySkus; | ||
|
||
/** | ||
* @param ResourceConnection $resourceConnection | ||
* @param GetProductIdsBySkusInterface $getProductIdsBySkus | ||
*/ | ||
public function __construct( | ||
ResourceConnection $resourceConnection, | ||
GetProductIdsBySkusInterface $getProductIdsBySkus | ||
) { | ||
$this->resourceConnection = $resourceConnection; | ||
$this->getProductIdsBySkus = $getProductIdsBySkus; | ||
} | ||
|
||
/** | ||
* @param string $sku | ||
* @param float $quantity | ||
* @param int $status | ||
* @return void | ||
*/ | ||
public function execute(string $sku, float $quantity, int $status) | ||
{ | ||
$productId = $this->getProductIdsBySkus->execute([$sku])[$sku]; | ||
|
||
$connection = $this->resourceConnection->getConnection(); | ||
$connection->update( | ||
$this->resourceConnection->getTableName('cataloginventory_stock_status'), | ||
[ | ||
StockStatusInterface::STOCK_STATUS => $status, | ||
StockStatusInterface::QTY => $quantity, | ||
], | ||
[ | ||
StockStatusInterface::PRODUCT_ID . ' = ?' => $productId, | ||
'website_id = ?' => 0, | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.