1

I've done some orders through Magento however I want to remove them now from Sales page to clean it up. I need to remove only test orders, there are also some real order which I don't wish to remove.

What approach shall I take?

Thanks

  • 1
  • Unfortunately not. I have real orders in the database I don't wish to remove. Plus I only wish to remove the orders. Not products, not reviews, just the orders. – zcoyne Feb 27 '18 at 11:02
  • then you have to delete test orders manually, or you can delete the test orders by id in a script – Piyush Feb 27 '18 at 11:03
  • Can you please explain HOW to remove delete the test order manually? I'm unsure hence why I asked the question. Thanks – zcoyne Feb 27 '18 at 11:04
  • there are extensions available to delete orders, you have to use one of them – Piyush Feb 27 '18 at 11:06
1

Removing Sample Data can easily be done through Database Queries.

I wrote a Codeblog about it which you can find here:

https://codeblog.experius.nl/magento-2-remove-sample-data-test-data/

It also contains Enterprise (Commerce) queries.

  • Thanks for sharing thing this!! – diazwatson Aug 9 at 16:41
0

You can read here: https://stackoverflow.com/questions/37861046/how-to-remove-test-orders-from-magento2 . I prefer to use a better delete orders extension https://www.mageplaza.com/magento-2-delete-orders/ It's free and easy to use again.

0

Tested in Magento 2.1.0

Be safe : make a backup of your sql first.

Use the sql below according to your needs :

SET FOREIGN_KEY_CHECKS=0;

# Clean order history
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;

# Clean order infos
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;
TRUNCATE TABLE `sales_creditmemo_grid`;
TRUNCATE TABLE `sales_creditmemo_item`;
TRUNCATE TABLE `sales_invoice`;
TRUNCATE TABLE `sales_invoiced_aggregated`;
TRUNCATE TABLE `sales_invoiced_aggregated_order`;
TRUNCATE TABLE `sales_invoice_comment`;
TRUNCATE TABLE `sales_invoice_grid`;
TRUNCATE TABLE `sales_invoice_item`;
TRUNCATE TABLE `sales_order`;
TRUNCATE TABLE `sales_order_address`;
TRUNCATE TABLE `sales_order_aggregated_created`;
TRUNCATE TABLE `sales_order_aggregated_updated`;
TRUNCATE TABLE `sales_order_grid`;
TRUNCATE TABLE `sales_order_item`;
TRUNCATE TABLE `sales_order_payment`;
TRUNCATE TABLE `sales_order_status_history`;
TRUNCATE TABLE `sales_order_tax`;
TRUNCATE TABLE `sales_order_tax_item`;
TRUNCATE TABLE `sales_payment_transaction`;
TRUNCATE TABLE `sales_refunded_aggregated`;
TRUNCATE TABLE `sales_refunded_aggregated_order`;
TRUNCATE TABLE `sales_shipment`;
TRUNCATE TABLE `sales_shipment_comment`;
TRUNCATE TABLE `sales_shipment_grid`;
TRUNCATE TABLE `sales_shipment_item`;
TRUNCATE TABLE `sales_shipment_track`;
TRUNCATE TABLE `sales_shipping_aggregated`;
TRUNCATE TABLE `sales_shipping_aggregated_order`;

# Clean cart infos
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;

# Reset indexes (if you want your orders number start back to 1
TRUNCATE TABLE sequence_invoice_1;
TRUNCATE TABLE sequence_order_1;
TRUNCATE TABLE sequence_shipment_1;
TRUNCATE TABLE sequence_creditmemo_1;


SET FOREIGN_KEY_CHECKS=1;

DO NOT TRUNCATE / EMPTY THE FOLLOWING :

  • sales_order_status
  • sales_sequence_meta
  • sales_sequence_profile
  • sales_order_status_label
  • sales_order_status_state

Thank you

protected by Community Jul 6 at 9:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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