Skip to content

Commit ea7b254

Browse files
author
Ganin, Roman(rganin)
committed
Merge pull request #327 from magento-troll/sprint37
[Troll] Bugfixes
2 parents 932b845 + 8192379 commit ea7b254

File tree

16 files changed

+19
-96
lines changed

16 files changed

+19
-96
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,6 @@ public function getDateRange($range, $customStart, $customEnd, $returnObjects =
457457
break;
458458
}
459459

460-
$dateStart->setTimezone(new \DateTimeZone('Etc/UTC'));
461-
$dateEnd->setTimezone(new \DateTimeZone('Etc/UTC'));
462-
463460
if ($returnObjects) {
464461
return [$dateStart, $dateEnd];
465462
} else {

app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -465,37 +465,4 @@ protected function _getTZOffsetTransitions($timezone, $from = null, $to = null)
465465

466466
return $tzTransitions;
467467
}
468-
469-
/**
470-
* Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ()
471-
*
472-
* @param null|mixed $store
473-
* @return string
474-
*/
475-
protected function _getStoreTimezoneUtcOffset($store = null)
476-
{
477-
return $this->_localeDate->scopeDate($store)->format('P');
478-
}
479-
480-
/**
481-
* Retrieve date in UTC timezone
482-
*
483-
* @param mixed $date
484-
* @return null|\DateTime
485-
*/
486-
protected function _dateToUtc($date)
487-
{
488-
if ($date === null) {
489-
return null;
490-
}
491-
492-
if ($date instanceof \DateTimeInterface) {
493-
$dateUtc = $date;
494-
} else {
495-
$dateUtc = new \DateTime($date);
496-
}
497-
498-
$dateUtc->setTimezone(new \DateTimeZone('UTC'));
499-
return $dateUtc->format('Y-m-d H:i:s');
500-
}
501468
}

app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ public function aggregate($from = null, $to = null)
9898
$mainTable = $this->getMainTable();
9999
$adapter = $this->_getWriteAdapter();
100100

101-
// convert input dates to UTC to be comparable with DATETIME fields in DB
102-
$from = $this->_dateToUtc($from);
103-
$to = $this->_dateToUtc($to);
104-
105101
if ($from !== null || $to !== null) {
106102
$subSelect = $this->_getTableDateRangeSelect(
107103
$this->getTable('report_event'),
@@ -114,7 +110,7 @@ public function aggregate($from = null, $to = null)
114110
$subSelect = null;
115111
}
116112
$this->_clearTableByDateRange($mainTable, $from, $to, $subSelect);
117-
// convert dates from UTC to current admin timezone
113+
// convert dates to current admin timezone
118114
$periodExpr = $adapter->getDatePartSql(
119115
$this->getStoreTZOffsetQuery(
120116
['source_table' => $this->getTable('report_event')],

app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ protected function _construct()
9696
*/
9797
public function aggregate($from = null, $to = null)
9898
{
99-
// convert input dates to UTC to be comparable with DATETIME fields in DB
100-
$from = $this->_dateToUtc($from);
101-
$to = $this->_dateToUtc($to);
102-
10399
$adapter = $this->_getWriteAdapter();
104100
//$this->_getWriteAdapter()->beginTransaction();
105101

@@ -117,7 +113,7 @@ public function aggregate($from = null, $to = null)
117113
}
118114

119115
$this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect);
120-
// convert dates from UTC to current admin timezone
116+
// convert dates to current admin timezone
121117
$periodExpr = $adapter->getDatePartSql(
122118
$this->getStoreTZOffsetQuery(
123119
['source_table' => $this->getTable('sales_order')],

app/code/Magento/Sales/Model/Resource/Report/Invoiced.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ protected function _construct()
3131
*/
3232
public function aggregate($from = null, $to = null)
3333
{
34-
// convert input dates to UTC to be comparable with DATETIME fields in DB
35-
$from = $this->_dateToUtc($from);
36-
$to = $this->_dateToUtc($to);
37-
3834
$this->_aggregateByOrderCreatedAt($from, $to);
3935
$this->_aggregateByInvoiceCreatedAt($from, $to);
4036

@@ -76,7 +72,7 @@ protected function _aggregateByInvoiceCreatedAt($from, $to)
7672
}
7773

7874
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
79-
// convert dates from UTC to current admin timezone
75+
// convert dates to current admin timezone
8076
$periodExpr = $adapter->getDatePartSql(
8177
$this->getStoreTZOffsetQuery(
8278
['source_table' => $sourceTable],
@@ -187,7 +183,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
187183
}
188184

189185
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
190-
// convert dates from UTC to current admin timezone
186+
// convert dates to current admin timezone
191187
$periodExpr = $adapter->getDatePartSql($this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to));
192188

193189
$columns = [

app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public function aggregate($from = null, $to = null)
4747
*/
4848
protected function _aggregateByField($aggregationField, $from, $to)
4949
{
50-
// convert input dates to UTC to be comparable with DATETIME fields in DB
51-
$from = $this->_dateToUtc($from);
52-
$to = $this->_dateToUtc($to);
53-
5450
$adapter = $this->_getWriteAdapter();
5551

5652
$adapter->beginTransaction();

app/code/Magento/Sales/Model/Resource/Report/Refunded.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ protected function _construct()
3131
*/
3232
public function aggregate($from = null, $to = null)
3333
{
34-
// convert input dates to UTC to be comparable with DATETIME fields in DB
35-
$from = $this->_dateToUtc($from);
36-
$to = $this->_dateToUtc($to);
37-
3834
$this->_aggregateByOrderCreatedAt($from, $to);
3935
$this->_aggregateByRefundCreatedAt($from, $to);
4036

@@ -65,7 +61,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
6561
}
6662

6763
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
68-
// convert dates from UTC to current admin timezone
64+
// convert dates to current admin timezone
6965
$periodExpr = $adapter->getDatePartSql(
7066
$this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to)
7167
);
@@ -162,7 +158,7 @@ protected function _aggregateByRefundCreatedAt($from, $to)
162158
}
163159

164160
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
165-
// convert dates from UTC to current admin timezone
161+
// convert dates to current admin timezone
166162
$periodExpr = $adapter->getDatePartSql(
167163
$this->getStoreTZOffsetQuery(
168164
['source_table' => $sourceTable],

app/code/Magento/Sales/Model/Resource/Report/Shipping.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ protected function _construct()
3131
*/
3232
public function aggregate($from = null, $to = null)
3333
{
34-
// convert input dates to UTC to be comparable with DATETIME fields in DB
35-
$from = $this->_dateToUtc($from);
36-
$to = $this->_dateToUtc($to);
37-
3834
$this->_aggregateByOrderCreatedAt($from, $to);
3935
$this->_aggregateByShippingCreatedAt($from, $to);
4036
$this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_SHIPPING_FLAG_CODE);
@@ -64,7 +60,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
6460
}
6561

6662
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
67-
// convert dates from UTC to current admin timezone
63+
// convert dates to current admin timezone
6864
$periodExpr = $adapter->getDatePartSql(
6965
$this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to)
7066
);
@@ -166,7 +162,7 @@ protected function _aggregateByShippingCreatedAt($from, $to)
166162
}
167163

168164
$this->_clearTableByDateRange($table, $from, $to, $subSelect);
169-
// convert dates from UTC to current admin timezone
165+
// convert dates to current admin timezone
170166
$periodExpr = $adapter->getDatePartSql(
171167
$this->getStoreTZOffsetQuery(
172168
['source_table' => $sourceTable],

app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public function aggregate($from = null, $to = null)
4949
*/
5050
protected function _aggregateByOrder($aggregationField, $from, $to)
5151
{
52-
$from = $this->_dateToUtc($from);
53-
$to = $this->_dateToUtc($to);
54-
5552
$table = $this->getMainTable();
5653
$sourceTable = $this->getTable('sales_order');
5754
$adapter = $this->_getWriteAdapter();
@@ -67,7 +64,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
6764

6865
$this->_clearTableByDateRange($table, $from, $to, $subSelect, false, $salesAdapter);
6966

70-
// convert dates from UTC to current admin timezone
67+
// convert dates to current admin timezone
7168
$periodExpr = $adapter->getDatePartSql(
7269
$this->getStoreTZOffsetQuery($sourceTable, $aggregationField, $from, $to, null, $salesAdapter)
7370
);

app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public function aggregate($from = null, $to = null)
4646
*/
4747
protected function _aggregateByOrder($aggregationField, $from, $to)
4848
{
49-
// convert input dates to UTC to be comparable with DATETIME fields in DB
50-
$from = $this->_dateToUtc($from);
51-
$to = $this->_dateToUtc($to);
52-
5349
$writeAdapter = $this->_getWriteAdapter();
5450
$salesAdapter = $this->_resources->getConnection('sales_read');
5551

@@ -69,7 +65,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
6965
}
7066

7167
$this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect, false, $salesAdapter);
72-
// convert dates from UTC to current admin timezone
68+
// convert dates to current admin timezone
7369
$periodExpr = $writeAdapter->getDatePartSql(
7470
$this->getStoreTZOffsetQuery(
7571
['e' => $this->getTable('sales_order')],

0 commit comments

Comments
 (0)