While saving product in backend,throws "Unable to save Stock Item".
I have tried after flushed the cache and reindexing but still exception throws.
I have reffered below link, but no luck
In exception log throws
[2019-04-09 11:04:50] main.CRITICAL: Unable to save Stock Item {"exception":"[object] (Magento\Framework\Exception\CouldNotSaveException(code: 0): Unable to save Stock Item at /var/www/html/vega/vendor/magento/module-catalog-inventory/Model/Stock/StockItemRepository.php:183, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
vega
.cataloginventory_stock_item
, CONSTRAINTCATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID
FOREIGN KEY (stock_id
) REFERENCEScataloginventory_stock
(stock_id
) ON DELETE CASCADE), query was: INSERT INTOcataloginventory_stock_item
(product_id
,stock_id
,qty
,min_qty
,use_config_min_qty
,is_qty_decimal
,backorders
,use_config_backorders
,min_sale_qty
,use_config_min_sale_qty
,max_sale_qty
,use_config_max_sale_qty
,is_in_stock
,low_stock_date
,notify_stock_qty
,use_config_notify_stock_qty
,manage_stock
,use_config_manage_stock
,stock_status_changed_auto
,use_config_qty_increments
,qty_increments
,use_config_enable_qty_inc
,enable_qty_increments
,is_decimal_divided
,website_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) at /var/www/html/vega/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 (vega
.cataloginventory_stock_item
, CONSTRAINTCATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID
FOREIGN KEY (stock_id
) REFERENCEScataloginventory_stock
(stock_id
) ON DELETE CASCADE) at /var/www/html/vega/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)"} []