Recently I upgraded My Magento 2.2.6 to 2.3, After upgrading I configured Multi Source Inventory, It is working as expected while creating new products (and products created after upgradation). But it is throwing error while updating old products (which were created before upgrading to 2.3).
Below error is thrown by system while saving old products-
The stock item was unable to be saved. Please try again.
In exception.log
there is below log for the error-
main.CRITICAL: The stock item was unable to be saved. Please try again. {"exception":"[object] (Magento\Framework\Exception\CouldNotSaveException(code: 0): The stock item was unable to be saved. Please try again. at
/magento_root/vendor/magento/module-catalog-inventory/Model/Stock/StockItemRepository.php:187,
Magento\\Framework\\Exception\\CouldNotSaveException(code: 0):
Could not save Source Item at/magento_root/vendor/magento/module-inventory/Model/SourceItem/Command/Handler/SourceItemsSaveHandler.php:78
, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento_db
.inventory_source_item
, CONSTRAINTINVENTORY_SOURCE_ITEM_SOURCE_CODE_INVENTORY_SOURCE_SOURCE_CODE
FOREIGN KEY (source_code
) REFERENCESinventory_source
(source_code
) ON DEL), query was: INSERT INTO inventory_source_item (source_code
,sku
,quantity
,status
) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATEquantity
= VALUES(quantity
),status
= VALUES(status
) at /magento_root/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento_root
.inventory_source_item
, CONSTRAINTINVENTORY_SOURCE_ITEM_SOURCE_CODE_INVENTORY_SOURCE_SOURCE_CODE
FOREIGN KEY (source_code
) REFERENCESinventory_source
(source_code
) ON DEL) at /magento_root/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)"} []
Does anyone have idea about this issue?