5

How to delete order in magento from order id 100000030 to 100000050 by using MySQL query.

  • Did you try delete order by programmitically ? – Hardik Visa Jan 3 '17 at 12:33
  • No,By MySQL query in database. – Kamlesh Jha Jan 3 '17 at 12:35
  • do you want to try ? I have code to delete order by programmitically – Hardik Visa Jan 3 '17 at 12:35
  • ok ,i will be try. – Kamlesh Jha Jan 3 '17 at 12:37
2

Following Code use to Delete order.

<?php
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);

$order=Mage::getModel('sales/order')->loadByIncrementId('you_order_id'); 
try {           
    Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId())->delete();
    echo "Order #" . $id . " is removed" . PHP_EOL;
    Mage::log("Order #" . $id . " is removed", null, "order-delete.log");
}
catch (Exception $e) 
{
    echo "Order #" . $id . " could not be remvoved: " . $e->getMessage() . PHP_EOL;
    Mage::log("Order #" . $id . " could not be remvoved: " . $e->getMessage(), null, "order-delete.log");
}
?>

It may be help you.

Here link of delete order best way as per your requirement

  • It's good but i don't want to delete programmatically.want to delete by query . – Kamlesh Jha Jan 3 '17 at 12:41
  • @KamleshJha I update my answer as per your requirment – Hardik Visa Jan 16 '17 at 10:02
2

Magento, basically store Order details at below tables

  • sales_flat_order
  • sales_flat_order_grid

if want to remove order then you need to delete respective table.So run below queries

Delete from sales_flat_order where increment_id in (100000030,100000050)
Delete from sales_flat_order_grid where increment_id in (100000030,100000050)
0

select @order_id:=entity_id from sales_order_entity where increment_id='100000001'; delete from sales_order_entity where entity_id=@order_id or parent_id=@order_id;

you can try above code for that.

0

As the poster wanted to delete a range of orders, those are the queries:

DELETE FROM sales_flat_order WHERE increment_id >= 100000030 AND increment_id <= 100000050; DELETE FROM sales_flat_order_grid WHERE increment_id >= 100000030 AND increment_id <= 100000050;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.