2

How to refresh statistics programmatically in Magento 1?

0

Create a custom php file at root level and use below code

<?php

    require_once "app/Mage.php";

    Mage::app();

    umask(0);

    ini_set('max_execution_time', 0);

    ini_set('memory_limit', '-1');

    set_time_limit(0);

    $row = 0;


    $allcodes = array(

    '0' => 'sales/report_order',

    '1' => 'tax/report_tax',

    '2' => 'sales/report_shipping',

    '3' => 'sales/report_invoiced',

    '4' => 'sales/report_refunded',

    '5' => 'salesrule/report_rule',

    '6' => 'sales/report_bestsellers',

    );



    try 

    {

        foreach ($allcodes as $collectionName) 

        {

            Mage::getResourceModel($collectionName)->aggregate();

            /// print_r($tr);


        }

        Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Lifetime statistics have been updated.'));

    } 

    catch (Mage_Core_Exception $e)

    {


        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());


    } 

    catch (Exception $e) 

    {

        Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to refresh lifetime statistics.'));

        Mage::logException($e);

    }


?>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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