简体   繁体   中英

How to delete all orders from Magento?

I'm trying to truncate sales_flat_order table. But i got below error

#1701 - Cannot truncate a table referenced in a foreign key constraint
(`dbmigrate1`.`sales_recurring_profile_order`, CONSTRAINT
`FK_7FF85741C66DCD37A4FBE3E3255A5A01` FOREIGN KEY (`order_id`)
REFERENCES `dbmigrate1`.`sales_flat_order` (`entity_id`))

But

Delete from sales_flat_order

empty order and order related other tables.

But actually I want to truncate the table.

You can run this SQL query:

 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; 

Use EM Delete order Module its working perfectly fine till latest release.

https://github.com/ffuenf/EM_DeleteOrder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM