Skip to content

Commit 4e0469a

Browse files
author
valdislav
committed
MAGETWO-35632: Refactor queries for Magento\Reports\Model\Resource\Quote\Collection
1 parent 1a70516 commit 4e0469a

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,14 @@ public function addSubtotal($storeIds = '', $filter = null)
241241
/**
242242
* Get select count sql
243243
*
244-
* @return string
244+
* @return \Magento\Framework\DB\Select
245245
*/
246246
public function getSelectCountSql()
247247
{
248-
$countSelect = clone $this->getSelect();
249-
$countSelect->reset(\Zend_Db_Select::ORDER);
250-
$countSelect->reset(\Zend_Db_Select::LIMIT_COUNT);
251-
$countSelect->reset(\Zend_Db_Select::LIMIT_OFFSET);
252-
$countSelect->reset(\Zend_Db_Select::COLUMNS);
253-
$countSelect->reset(\Zend_Db_Select::GROUP);
254-
$countSelect->resetJoinLeft();
255-
$countSelect->columns("COUNT(DISTINCT main_table.entity_id)");
248+
$countSelect = clone $this->prepareActiveCartItems();
249+
$countSelect->reset(\Zend_Db_Select::COLUMNS)
250+
->reset(\Zend_Db_Select::GROUP)
251+
->columns('COUNT(DISTINCT quote_items.product_id)');
256252
return $countSelect;
257253
}
258254

app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public function testGetSelectCountSql()
3939
false
4040
);
4141

42-
$collection->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
42+
$collection->expects($this->once())->method('prepareActiveCartItems')->willReturn($this->selectMock);
4343
$this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf();
4444
$this->selectMock->expects($this->once())
4545
->method('columns')
46-
->with('COUNT(DISTINCT main_table.entity_id)')
46+
->with('COUNT(DISTINCT quote_items.product_id)')
4747
->willReturnSelf();
4848
$this->assertEquals($this->selectMock, $collection->getSelectCountSql());
4949
}

0 commit comments

Comments
 (0)