I was using the Magento 2.3.2 normally, but since I updated to Magento 2.3.3 I'm not able to create a new product anymore. I'm receiving this message below.
The stock item was unable to be saved. Please try again.
My exception.log is logging this message:
[2019-11-06 17:30:42] 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 /Users/rafael/dev/mystoremagento/vendor/magento/module-catalog-inventory/Model/Stock/StockItemRepository.php:187, Magento\Framework\Exception\CouldNotSaveException(code: 0): Could not save Source Item at /Users/rafael/dev/mystoremagento/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 (
mystoremagento
.inventory_source_item
, CONSTRAINTINVENTORY_SOURCE_ITEM_SOURCE_CODE_INVENTORY_SOURCE_SOURCE_CODE
FOREIGN KEY (source_code
) REFERENCESinventory_source
(source_code
) ), query was: INSERT INTOinventory_source_item
(source_code
,sku
,quantity
,status
) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATEquantity
= VALUES(quantity
),status
= VALUES(status
) at /Users/rafael/dev/mystoremagento/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mystoremagento
.inventory_source_item
, CONSTRAINTINVENTORY_SOURCE_ITEM_SOURCE_CODE_INVENTORY_SOURCE_SOURCE_CODE
FOREIGN KEY (source_code
) REFERENCESinventory_source
(source_code
) ) at /Users/rafael/dev/mystoremagento/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []
Even doing these tests it doesn't work:
- Disabling all third-party module
- Running the install process (using the same DB)
- Exporting and importing the DB