Clear out test data from a Magento store

So – you’ve got your transactional emails set up, your shipping is working, your payment method is all sorted and you’re ready to launch your Magento store to the world. Except you’ve got a load of junk cluttering up the place from your testing. Here’s the quick and easy guide on how to delete test data from Magento to declutter the store so it’s nice and clean ready for your first customers!

Clear out test orders

Surprisingly, Magento doesn’t come with the ability to delete orders…you can credit memo which will mark them as cancelled, but it doesn’t remove them from the order list, and their data will still show up in reports.

The best module out there, that I’ve found, is EM Seamless Delete Order (not the greatest of names), which is available on Magento Connect here, and which can be installed through the Magento Downloader. Once installed it adds an option to the bottom of the Mass Actions menu in the order list (in Sales / Orders), so you can bulk select any test orders and delete them with a single click.

Clear out test customers

Simple enough – go into Customers / Manage Customers, select all, and delete.

Clear out test search terms

Also simple enough – go into Catalogue / Search Terms, select all, and delete.

Clear out bestsellers and most viewed products on the dashboard

You’ll need database access for this, ideally, through PHPMyAdmin or your database editor of choice. Once in the database you need to execute SQL commands to truncate a number of tables to clear the bestsellers’ lists :

TRUNCATE TABLE sales_bestsellers_aggregated_daily;
TRUNCATE TABLE sales_bestsellers_aggregated_monthly;
TRUNCATE TABLE sales_bestsellers_aggregated_yearly;

And then one more command while you’re there to clear out the list of most viewed products :

TRUNCATE TABLE `report_event`;

And finally, one more to reset the search count to zero :

UPDATE `catalogsearch_query` SET `num_results`=0, `popularity`=0;

And that’s it – you’re good to go!