Question

I expected that the magento reporting (specifically, sales > orders report) would bucket days by local time.

This doesn't seem like it's the case, at least on magento 1.14.2.2. By comparing the raw orders with the order report, it is clear that some orders are not bucketed correctly in the report, because it's bucketing by UTC as opposed to local timezone.

The timezone is set correctly in the system, and lifetime statistics have been refreshed.

I have tried with Magento 1.9.2.2 and the result seems to be bucketed by local timezone. I guess this means it could be a configuration issue, or perhaps a bug?

Can anyone confirm or deny this issue?

Was it helpful?

Solution

I can confirm this behavior on 1.14.2.3, and it seems like it's a bug.

If you look at how the report aggregation works, you'll find that in Mage_Reports_Model_Resource_Report_Abstract::_getTableDateRangeSelect() the group by date is done like this:

$select  = $adapter->select()
    ->from(
        array($alias => $table),
        $adapter->getDatePartSql(
            $this->getStoreTZOffsetQuery(array($alias => $table), $alias . '.' . $column, $from, $to)
        )
    )
    ->distinct(true);

Where getStoreTZOffsetQuery() is supposed to do a timezone conversion from UTC to the current admin timezone.

I did not debug further to find out where it goes wrong, so unfortunately I don't have a fix for this either.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top