Undo Order Cancel in Magento

If you want to restore canceled order, rollback order cancellation and undo order cancel action in Magento and Magento 2 use the following SQL query. Order will be restored to “Pending” status.

SET @ORDERID = "41970";
UPDATE `sales_order`
SET `state` = 'new',
`status` = 'pending',
`base_discount_canceled` = '0',
`base_shipping_canceled` = '0',
`base_subtotal_canceled` = '0',
`base_tax_canceled` = '0',
`base_total_canceled` = '0',
`discount_canceled` = '0',
`shipping_canceled` = '0',
`subtotal_canceled` = '0',
`tax_canceled` = '0',
`total_canceled` = '0'
WHERE `entity_id` = @ORDERID;
UPDATE `sales_order_item`
SET `qty_canceled` = '0',
`tax_canceled` = '0',
`discount_tax_compensation_canceled` = '0'
WHERE (`order_id` = @ORDERID);
DELETE FROM `sales_payment_transaction`
WHERE (`order_id` = @ORDERID) and `txn_type` = 'void';
UPDATE `sales_payment_transaction`
SET `is_closed` = 0
WHERE (`order_id` = @ORDERID) and `txn_type` = 'authorization';
Share
2019   magento 1   magento 2   magento2   mysql   order   sql
1 comment
deresh pillay 3 mo

how do I use this in mysql cli

Denis Obukhov 3 mo

Just copy the query, paste into a text editor, replace the order id and again copy the text. You can paste it into mysql cli and press enter