HummingbirdUK main logo


Coding solutions to business problems

About us

We use code to create solutions to business challenges, bottle-necks and headaches.

If you think your business has a problem that can be solved through code, we are happy to chat things through without any obligation.

Get in touch

Clear most viewed products list programmatically in Magento

Home / Blog / Clear most viewed products list programmatically in Magento

Written by Giles Bennett

In an earlier post I wrote about how to clear test data out from a store - it would appear that a lot of people are looking specifically for a way to clear the "most viewed" products list or "recently viewed" products list from Magento.

Clear Most-Viewed Products List

Below is a simple script to do just that, even if you don't have direct access to the database (through phpMyAdmin, or similar). Start off in the usual way : [php] <?php require_once('app/Mage.php'); Mage::app('default'); [/php] Then connect to the database : [php] $resource = Mage::getSingleton('core/resource')->getConnection('core_read'); [/php] And then get the relevant table name (this method of doing so takes into account any prefix that you may have set for your database tables) : [php] $tableName = $resource->getTableName('report_event'); [/php] Finally, truncate the table and report back that that's been done : [php] $resource->query("truncate table " . $tableName); echo $tableName . " has been truncated"; ?> [/php] And that's it. The entire script is available to download below - just upload it to the web root of your installation, hit it in the browser, and you're done. Of course, if you do have direct database access then just use the mySQL command "truncate table report_event;" to get the same effect. Entirely up to you!
Author : Giles Bennett

About the author

Giles Bennett built his first website in 1996, and is old enough to miss Netscape Navigator. Initially a lawyer, he jumped ship to IT in 2008, and after 5 years as a freelancer, he founded HummingbirdUK in 2013. He can be reached by email at