Skip to content

Commit b12a471

Browse files
committed
MC-37934: Unexpected behavior of "Manage Shopping Cart" regarding "Products in the Comparison List"
1 parent 51b53be commit b12a471

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

app/code/Magento/Reports/Model/ResourceModel/Event.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function applyLogToCollection(
9393
$skipIds = []
9494
) {
9595
$idFieldName = $collection->getResource()->getIdFieldName();
96+
$predefinedStoreIds = ($collection->getStoreId() === null) ?: [$collection->getStoreId()];
9697

9798
$derivedSelect = $this->getConnection()
9899
->select()
@@ -103,7 +104,7 @@ public function applyLogToCollection(
103104
->where('event_type_id = ?', (int) $eventTypeId)
104105
->where('subject_id = ?', (int) $eventSubjectId)
105106
->where('subtype = ?', (int) $subtype)
106-
->where('store_id IN(?)', $this->getCurrentStoreIds())
107+
->where('store_id IN(?)', $this->getCurrentStoreIds($predefinedStoreIds))
107108
->group('object_id');
108109

109110
if ($skipIds) {
@@ -132,13 +133,11 @@ public function getCurrentStoreIds(array $predefinedStoreIds = null)
132133
{
133134
$stores = [];
134135
// get all or specified stores
135-
if ($this->_storeManager->getStore()->getId() == 0) {
136-
if (null !== $predefinedStoreIds) {
137-
$stores = $predefinedStoreIds;
138-
} else {
139-
foreach ($this->_storeManager->getStores() as $store) {
140-
$stores[] = $store->getId();
141-
}
136+
if ($predefinedStoreIds !== null) {
137+
$stores = $predefinedStoreIds;
138+
} else if ($this->_storeManager->getStore()->getId() == 0) {
139+
foreach ($this->_storeManager->getStores() as $store) {
140+
$stores[] = $store->getId();
142141
}
143142
} else {
144143
// get all stores, required by configuration in current store scope

app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ public function testApplyLogToCollection()
174174
->expects($this->any())
175175
->method('getSelect')
176176
->willReturn($collectionSelectMock);
177+
$collectionMock
178+
->expects($this->any())
179+
->method('getStoreId')
180+
->willReturn(1);
177181

178182
$selectMock = $this->getMockBuilder(Select::class)
179183
->disableOriginalConstructor()

0 commit comments

Comments
 (0)