Skip to content

Commit ec57ca7

Browse files
author
Ganin, Roman(rganin)
committed
Merge pull request #433 from magento-troll/Troll_S40_bugfix
[Troll] bugfixes
2 parents 6bfde04 + 050cfdb commit ec57ca7

File tree

7 files changed

+34
-18
lines changed

7 files changed

+34
-18
lines changed

app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getCountTotals()
303303

304304
$this->_addOrderStatusFilter($totalsCollection, $filterData);
305305

306-
if (count($totalsCollection->getItems()) < 1 || !$filterData->getData('from')) {
306+
if ($totalsCollection->load()->getSize() < 1 || !$filterData->getData('from')) {
307307
$this->setTotals(new \Magento\Framework\Object());
308308
$this->setCountTotals(false);
309309
} else {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ protected function _getSelectedColumns()
102102
}
103103

104104
/**
105-
* Add selected data
105+
* Apply custom columns before load
106106
*
107107
* @return $this
108108
*/
109-
protected function _initSelect()
109+
protected function _beforeLoad()
110110
{
111111
$this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
112112
if (!$this->isTotals()) {
113113
$this->getSelect()->group($this->_periodFormat);
114114
}
115-
return parent::_initSelect();
115+
return parent::_beforeLoad();
116116
}
117117
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ protected function _getSelectedColumns()
8383
}
8484

8585
/**
86-
* Add selected data
86+
* Apply custom columns before load
8787
*
88-
* @return \Magento\Sales\Model\Resource\Report\Refunded\Collection\Order
88+
* @return $this
8989
*/
90-
protected function _initSelect()
90+
protected function _beforeLoad()
9191
{
9292
$this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
9393
if (!$this->isTotals()) {
9494
$this->getSelect()->group($this->_periodFormat);
9595
}
96-
return parent::_initSelect();
96+
return parent::_beforeLoad();
9797
}
9898
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ protected function _getSelectedColumns()
8787
}
8888

8989
/**
90-
* Add selected data
90+
* Apply custom columns before load
9191
*
9292
* @return $this
9393
*/
94-
protected function _initSelect()
94+
protected function _beforeLoad()
9595
{
9696
$this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
9797

@@ -101,6 +101,6 @@ protected function _initSelect()
101101
if ($this->isSubTotals()) {
102102
$this->getSelect()->group([$this->_periodFormat]);
103103
}
104-
return parent::_initSelect();
104+
return parent::_beforeLoad();
105105
}
106106
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ protected function _getSelectedColumns()
8585
}
8686

8787
/**
88-
* Add selected data
88+
* Apply custom columns before load
8989
*
9090
* @return $this
9191
*/
92-
protected function _initSelect()
92+
protected function _beforeLoad()
9393
{
9494
$this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
9595
if (!$this->isTotals() && !$this->isSubTotals()) {
@@ -99,6 +99,6 @@ protected function _initSelect()
9999
if ($this->isSubTotals()) {
100100
$this->getSelect()->group([$this->_periodFormat]);
101101
}
102-
return parent::_initSelect();
102+
return parent::_beforeLoad();
103103
}
104104
}

dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function processAssert(
3434
$this->order = $order;
3535
$this->searchInSalesReportGrid($salesReport);
3636
$salesResult = $this->prepareSalesResult($salesReportPage->getGridBlock()->getLastResult());
37-
$prepareInitialResult = $this->prepareExpectedResult($initialSalesResult);
37+
$prepareInitialResult = $this->prepareSalesResult($this->prepareExpectedResult($initialSalesResult));
3838
\PHPUnit_Framework_Assert::assertEquals(
3939
$prepareInitialResult,
4040
$salesResult,
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
5252
{
5353
$data = [];
5454
foreach ($salesResult as $key => $result) {
55-
$data[$key] = intval($result);
55+
$data[$key] = floatval($result);
5656
}
5757

5858
return $data;

dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,31 @@ public function processAssert(
3333
$this->salesReportPage = $salesReportPage;
3434
$this->order = $order;
3535
$this->searchInSalesReportGrid($salesReport);
36-
$salesResult = $salesReportPage->getGridBlock()->getTotalResult();
37-
$prepareInitialResult = $this->prepareExpectedResult($initialSalesTotalResult);
36+
$salesResult = $this->prepareSalesResult($salesReportPage->getGridBlock()->getTotalResult());
37+
$prepareInitialResult = $this->prepareSalesResult($this->prepareExpectedResult($initialSalesTotalResult));
3838
\PHPUnit_Framework_Assert::assertEquals(
3939
$prepareInitialResult,
4040
$salesResult,
4141
"Grand total Sales result is not correct."
4242
);
4343
}
4444

45+
/**
46+
* Prepare sales result.
47+
*
48+
* @param array $salesResult
49+
* @return array
50+
*/
51+
protected function prepareSalesResult($salesResult)
52+
{
53+
$data = [];
54+
foreach ($salesResult as $key => $result) {
55+
$data[$key] = floatval($result);
56+
}
57+
58+
return $data;
59+
}
60+
4561
/**
4662
* Returns a string representation of the object
4763
*

0 commit comments

Comments
 (0)