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 require_once('app/Mage.php'); Mage::app('default');
Then connect to the database :
$resource = Mage::getSingleton('core/resource')->getConnection('core_read');
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) :
$tableName = $resource->getTableName('report_event');
Finally, truncate the table and report back that that’s been done :
$resource->query("truncate table " . $tableName); echo $tableName . " has been truncated"; ?>
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!