Skip to content

Commit 06c71d6

Browse files
committed
Merge remote-tracking branch 'troll/MAGETWO-48527' into troll-bugs
2 parents 088d221 + faf84f1 commit 06c71d6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function resolveCustomerNames()
156156

157157
$select->from(
158158
['customer' => $this->customerResource->getTable('customer_entity')],
159-
['email']
159+
['entity_id', 'email']
160160
);
161161
$select->columns(
162162
['customer_name' => $customerName]
@@ -171,8 +171,11 @@ public function resolveCustomerNames()
171171
$customersData = $this->customerResource->getConnection()->fetchAll($select);
172172

173173
foreach ($this->getItems() as $item) {
174-
$item->setData(array_merge($item->getData(), current($customersData)));
175-
next($customersData);
174+
foreach ($customersData as $customerItemData) {
175+
if ($item['customer_id'] == $customerItemData['entity_id']) {
176+
$item->setData(array_merge($item->getData(), $customerItemData));
177+
}
178+
}
176179
}
177180
}
178181
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,14 @@ public function testResolveCustomerNames()
110110
$customerName = "CONCAT_WS('firstname', 'lastname')";
111111
$customerTableName = 'customer_entity';
112112
$customerId = ['customer_id' => ['test_id']];
113-
$customersData = [['item_1']];
114-
$itemData = ['test'];
113+
$customersData = [['entity_id' => 'test_id', 'name' => 'item_1']];
115114

116115
$this->selectMock->expects($this->any())
117116
->method('getConnection')
118117
->willReturn($this->connectionMock);
119118
$this->selectMock->expects($this->once())
120119
->method('from')
121-
->with(['customer' => $customerTableName], ['email'])
120+
->with(['customer' => $customerTableName], ['entity_id', 'email'])
122121
->willReturnSelf();
123122
$this->selectMock->expects($this->once())
124123
->method('columns')
@@ -158,9 +157,6 @@ public function testResolveCustomerNames()
158157
$itemMock = $this->getMockBuilder('Magento\Framework\Model\AbstractModel')
159158
->disableOriginalConstructor()
160159
->getMock();
161-
$itemMock->expects($this->once())
162-
->method('getData')
163-
->willReturn($itemData);
164160

165161
$this->entityFactoryMock->expects($this->any())
166162
->method('create')

0 commit comments

Comments
 (0)