Created
May 7, 2025 11:13
-
-
Save vasilii-b/033899aa97b4547c22bdb723815badf1 to your computer and use it in GitHub Desktop.
Filter out the SKUs that aren't in the catalog when there is request to save the SKUs inventory. #MSI | Magento 2 / Adobe Commerce
This file contains hidden or 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
--- a/vendor/magento/module-inventory/Model/ResourceModel/SourceItem/SaveMultiple.php 2025-02-27 15:30:53 | |
+++ b/vendor/magento/module-inventory/Model/ResourceModel/SourceItem/SaveMultiple.php 2025-05-07 13:19:48 | |
@@ -135,6 +135,19 @@ | |
$stock[] = $sourceItem->getSourceCode(); | |
} | |
+ // check if skus are present in catalog_product_entity table | |
+ // and include into updates only those that are present | |
+ $existingSkusSelect = $connection->select(); | |
+ $existingSkusSelect->from( | |
+ $this->resourceConnection->getTableName('catalog_product_entity'), | |
+ ['sku'] | |
+ ); | |
+ $existingSkusSelect->where( | |
+ 'sku IN (?)', $skus | |
+ ); | |
+ $skus = $connection->fetchCol($existingSkusSelect); | |
+ // end of check for existing skus | |
+ | |
$storedSourceItems = $connection->fetchAll( | |
$connection->select() | |
->from($tableName, ['source_item_id', 'source_code', 'sku']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment