I'm wondering if anyone knows what I would need to do to adjust the dashboard to show the last day (since midnight) instead of the last 24 hours.
Asked
Active
Viewed 372 times
3
-
You mean to change the text? – TBI Infotech Aug 02 '14 at 07:02
-
No I don't mean to just change the text. I would like it to show more useful information. As in how much I sold today, VS the last 24 hours so I have a defined start and stop period where I can really tell how my business is doing. – Brad Aug 05 '14 at 02:15
1 Answers
2
You have to rewrite the block Mage_Reports_Model_Resource_Order_Collection and override the method getDateRange as follows:
public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
{
$dateEnd = Mage::app()->getLocale()->date();
$dateStart = clone $dateEnd;
// go to the end of a day
$dateEnd->setHour(23);
$dateEnd->setMinute(59);
$dateEnd->setSecond(59);
$dateStart->setHour(0);
$dateStart->setMinute(0);
$dateStart->setSecond(0);
switch ($range)
{
case '24h':
$dateEnd = Mage::app()->getLocale()->date();
$dateEnd->addHour(1);
$dateStart = clone $dateEnd;
// OLD: use the last 24 hours
// $dateStart->subDay(1);
// NEW: use the current day since midnight
$dateStart->setMilliSecond(0);
$dateStart->setSecond(0);
$dateStart->setMinute(0);
$dateStart->setHour(0);
break;
case '7d':
// substract 6 days we need to include
// only today and not hte last one from range
$dateStart->subDay(6);
break;
case '1m':
$dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
break;
case 'custom':
$dateStart = $customStart ? $customStart : $dateEnd;
$dateEnd = $customEnd ? $customEnd : $dateEnd;
break;
case '1y':
case '2y':
$startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
$startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
$startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
$dateStart->setMonth($startMonth);
$dateStart->setDay($startDay);
if ($range == '2y') {
$dateStart->subYear(1);
}
break;
}
$dateStart->setTimezone('Etc/UTC');
$dateEnd->setTimezone('Etc/UTC');
if ($returnObjects) {
return array($dateStart, $dateEnd);
} else {
return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
}
}
The code in the case '24h' block has been changed. This should be enough.
Hint: Grep for 24h under app/code/core/Mage to find all the places which are relevant for this functionality.
Simon
- 5,735
- 1
- 32
- 70