Posts

Showing posts from 2022

Magento 2: Delete sample data and test data from your store

Here is a script to delete all the test data from your magento store. This can come in handy especially at the time of launching your website from beta to production mode. Don't forget to bookmark it for your next launch. NOTE: It is advisable to take full database backup before performing any operations below: SCRIPT: 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