When executing the following:
$product = Mage::getModel('catalog/product')->load($id); $stock_item = $product->getStockItem(); $stock_item->setIsInStock(true); $stock_item->save(); //...other product edits... $product->save();
For a very small amount of products (~13 or so) in the store (~10k SKUs) the following exception is raised:
SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`cataloginventory_stock_item`, CONSTRAINT `FK_CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID` FOREIGN KEY (`stock_id`) REFERENCES `cataloginventory_stock` (`stock_id`) ON DE...
Again, this is a very small number of items many of which are defunct. There have been no manual db edits, but, I'm curious if there are others that have this issue that I don't/won't know about. Is there a way to handle this or to rectify this at the db level?