There are 3 different tables that stores product viewed count

  • report_viewed_product_aggregated_daily
  • report_viewed_product_aggregated_monthly
  • report_viewed_product_aggregated_yearly

If I want to get current viewed count of a product, I can get it from any one of these tables. But the problem is, whenever I open the product on frontend, none of these tables are showing any result related to that product.

Is it a magento builtin issue?

I thought I need to set Magento cron to update these tables instantly when user open the product, but it also not worked for me.

  • Not getting any response :( Jun 19, 2019 at 10:03
  • At first I didn't know my reputation will deduct after starting bounty :D Jun 24, 2019 at 4:34

3 Answers 3


These tables would not update on runtime

You need to run Refresh Statistics from:

Reports -> Statistics -> Refresh Statistics

If you want to run it from cronjob follow this link: https://magento.stackexchange.com/a/243187/31910

  • This really satisfying. Thanks for clarification :) Jun 24, 2019 at 4:30

Go to Admin -> Reports -> Refresh Statistics, then select the reports you want to refresh, then hit the submit button.

Once refresh, go back to the report, and select the required to and from dates, then click on the show reports button.

You should see the report as required.

If there is still nothing, the you may need to dig around in the report_viewed_product_* tables and see if there is in fact any data there.


After the answer @Shoaib Munir & @Rk Rathod, These tables would not update on runtime so you need to run Refresh Statistics from Reports -> Statistics -> Refresh Statistics every times. but if you don't want to refresh Statistics manually every time so you may set cron for that so it will refresh Statistics automatically.

First, you need to pass reportTypes argument to your cron class by using di.xml like below (I have passed all the arguments you may pass as per your requirement).

<type name="Vendor\Module\Cron\CronFile">
            <argument name="reportTypes" xsi:type="array">
                <item name="sales" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Order</item>
                <item name="tax" xsi:type="string">Magento\Tax\Model\ResourceModel\Report\Tax</item>
                <item name="shipping" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Shipping</item>
                <item name="invoiced" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Invoiced</item>
                <item name="refunded" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Refunded</item>
                <item name="coupons" xsi:type="string">Magento\SalesRule\Model\ResourceModel\Report\Rule</item>
                <item name="bestsellers" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Bestsellers</item>
                <item name="viewed" xsi:type="string">Magento\Reports\Model\ResourceModel\Report\Product\Viewed</item>

Then in your cron file should be like this.

namespace Vendor\Module\Cron;
use Magento\Reports\Model\ResourceModel\Refresh\Collection;

class CronFile extends Collection
    protected $logger;
    protected $reportTypes;

    public function __construct(
        \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
        \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
        \Magento\Reports\Model\FlagFactory $reportsFlagFactory,
        \Psr\Log\LoggerInterface $logger,
        array $reportTypes
    ) {
        $this->logger = $logger;
        $this->reportTypes = $reportTypes;
     * @return $this
    public function execute()
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

        try {
            $codes = $this->loadData();

            foreach ($codes->_items as $codek=>$codev) {
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
        } catch (\Exception $e) {
        return $this;

I hope it helps!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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