Skip to content

Commit cba2411

Browse files
committed
Added today to dashboard report
1 parent ed5c06d commit cba2411

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

app/code/Magento/Backend/Model/Dashboard/Chart/Date.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function getByPeriod(string $period): array
6363

6464
if ($period === Period::PERIOD_24_HOURS) {
6565
$dateEnd->modify('-1 hour');
66+
} elseif ($period === Period::PERIOD_TODAY) {
67+
$dateEnd->modify('now');
6668
} else {
6769
$dateEnd->setTime(23, 59, 59);
6870
$dateStart->setTime(0, 0, 0);

app/code/Magento/Backend/Model/Dashboard/Period.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
class Period
1414
{
15+
public const PERIOD_TODAY = 'today';
1516
public const PERIOD_24_HOURS = '24h';
1617
public const PERIOD_7_DAYS = '7d';
1718
public const PERIOD_1_MONTH = '1m';
@@ -30,6 +31,7 @@ class Period
3031
public function getDatePeriods(): array
3132
{
3233
return [
34+
static::PERIOD_TODAY => __('Today'),
3335
static::PERIOD_24_HOURS => __('Last 24 Hours'),
3436
static::PERIOD_7_DAYS => __('Last 7 Days'),
3537
static::PERIOD_1_MONTH => __('Current Month'),
@@ -46,6 +48,7 @@ public function getDatePeriods(): array
4648
public function getPeriodChartUnits(): array
4749
{
4850
return [
51+
static::PERIOD_TODAY => self::PERIOD_UNIT_HOUR,
4952
static::PERIOD_24_HOURS => self::PERIOD_UNIT_HOUR,
5053
static::PERIOD_7_DAYS => self::PERIOD_UNIT_DAY,
5154
static::PERIOD_1_MONTH => self::PERIOD_UNIT_DAY,

app/code/Magento/Reports/Model/ResourceModel/Order/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
318318
protected function _getRangeExpression($range)
319319
{
320320
switch ($range) {
321+
case 'today':
321322
case '24h':
322323
$expression = $this->getConnection()->getConcatSql(
323324
[
@@ -420,6 +421,9 @@ public function getDateRange($range, $customStart, $customEnd, $returnObjects =
420421
$dateStart->setTime(0, 0, 0);
421422

422423
switch ($range) {
424+
case 'today':
425+
$dateEnd->modify('now');
426+
break;
423427
case '24h':
424428
$dateEnd = new \DateTime();
425429
$dateEnd->modify('+1 hour');

0 commit comments

Comments
 (0)