jreinke / magento-stock-movements

Magento extension to save products stock movements.
http://www.bubblecode.net/en/2012/02/07/magento-save-product-stock-moves/
79 stars 50 forks source link

Issue with DB #13

Open Omi0 opened 10 years ago

Omi0 commented 10 years ago

It looks like I have found an issue. When you are trying to edit old orders with products which were delited from the catalogue a long time ago, I am gettin following issue:

a:5:{i:0;s:308:"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (tankards.ru.bubble_stock_movement, CONSTRAINT FK_STOCK_MOVEMENT_ITEM FOREIGN KEY (item_id) REFERENCES cataloginventory_stock_item (item_id) ON DELETE CASCADE ON UPDATE CASCADE)";i:1;s:3231:"#0 /var/www/tankards.ru/htdocs/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

1 /var/www/tankards.ru/htdocs/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)

2 /var/www/tankards.ru/htdocs/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)

3 /var/www/tankards.ru/htdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `bu...', Array)

4 /var/www/tankards.ru/htdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `bu...', Array)

5 /var/www/tankards.ru/htdocs/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `bu...', Array)

6 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('bubble_stock_mo...', Array)

7 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Bubble_StockMovements_Model_Stock_Movement))

8 /var/www/tankards.ru/htdocs/app/code/community/Bubble/StockMovements/Model/Stock/Observer.php(134): Mage_Core_Model_Abstract->save()

9 /var/www/tankards.ru/htdocs/app/code/community/Bubble/StockMovements/Model/Stock/Observer.php(36): Bubble_StockMovements_Model_Stock_Observer->insertStockMovement(Object(Mage_CatalogInventory_Model_Stock_Item), 'Product restock...')

10 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Model/App.php(1338): Bubble_StockMovements_Model_Stock_Observer->cancelOrderItem(Object(Varien_Event_Observer))

11 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Bubble_StockMovements_Model_Stock_Observer), 'cancelOrderItem', Object(Varien_Event_Observer))

12 /var/www/tankards.ru/htdocs/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('sales_order_ite...', Array)

13 /var/www/tankards.ru/htdocs/app/code/core/Mage/Sales/Model/Order/Item.php(512): Mage::dispatchEvent('sales_order_ite...', Array)

14 /var/www/tankards.ru/htdocs/app/code/core/Mage/Sales/Model/Order.php(1164): Mage_Sales_Model_Order_Item->cancel()

15 /var/www/tankards.ru/htdocs/app/code/core/Mage/Sales/Model/Order.php(1137): Mage_Sales_Model_Order->registerCancellation()

16 /var/www/tankards.ru/htdocs/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(359): Mage_Sales_Model_Order->cancel()

17 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Adminhtml_Sales_OrderController->massCancelAction()

18 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('massCancel')

19 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))

20 /var/www/tankards.ru/htdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()

21 /var/www/tankards.ru/htdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)

22 /var/www/tankards.ru/htdocs/index.php(87): Mage::run('', 'store')