Skip to content

Commit ff8a3b5

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-4249' into PR_2025_10_21_muntianu
2 parents 13bd726 + d5a511c commit ff8a3b5

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

app/code/Magento/Catalog/CustomerData/CompareProducts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getSectionData()
8484
'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count),
8585
'listUrl' => $this->urlBuilder->getUrl('catalog/product_compare/index'),
8686
'items' => $count ? $this->getItems() : [],
87-
'websiteId' => $this->storeManager->getWebsite()->getId()
87+
'storeId' => $this->storeManager->getStore()->getId()
8888
];
8989
}
9090

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ public function getItemCollection()
298298

299299
/* update compare items count */
300300
$count = count($this->_itemCollection);
301-
$counts[$this->_storeManager->getWebsite()->getId()] = $count;
302-
$this->_catalogSession->setCatalogCompareItemsCountPerWebsite($counts);
301+
$counts[$this->_storeManager->getStore()->getId()] = $count;
302+
$this->_catalogSession->setCatalogCompareItemsCountPerStoreView($counts);
303303
$this->_catalogSession->setCatalogCompareItemsCount($count); //deprecated
304304
}
305305

@@ -330,8 +330,8 @@ public function calculate($logout = false)
330330
->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds());
331331

332332
$count = $collection->getSize();
333-
$counts[$this->_storeManager->getWebsite()->getId()] = $count;
334-
$this->_catalogSession->setCatalogCompareItemsCountPerWebsite($counts);
333+
$counts[$this->_storeManager->getStore()->getId()] = $count;
334+
$this->_catalogSession->setCatalogCompareItemsCountPerStoreView($counts);
335335
$this->_catalogSession->setCatalogCompareItemsCount($count); //deprecated
336336

337337
return $this;
@@ -344,13 +344,13 @@ public function calculate($logout = false)
344344
*/
345345
public function getItemCount()
346346
{
347-
$counts = $this->_catalogSession->getCatalogCompareItemsCountPerWebsite() ?: [];
348-
if (!isset($counts[$this->_storeManager->getWebsite()->getId()])) {
347+
$counts = $this->_catalogSession->getCatalogCompareItemsCountPerStoreView() ?: [];
348+
if (!isset($counts[$this->_storeManager->getStore()->getId()])) {
349349
$this->calculate();
350-
$counts = $this->_catalogSession->getCatalogCompareItemsCountPerWebsite() ?: [];
350+
$counts = $this->_catalogSession->getCatalogCompareItemsCountPerStoreView() ?: [];
351351
}
352352

353-
return $counts[$this->_storeManager->getWebsite()->getId()] ?? 0;
353+
return $counts[$this->_storeManager->getStore()->getId()] ?? 0;
354354
}
355355

356356
/**

app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Framework\UrlInterface;
2121
use Magento\Store\Model\StoreManagerInterface;
2222
use Magento\Store\Model\Website;
23+
use Magento\Store\Model\Store;
2324
use PHPUnit\Framework\MockObject\MockObject;
2425
use PHPUnit\Framework\TestCase;
2526

@@ -64,9 +65,9 @@ class CompareProductsTest extends TestCase
6465
private $storeManagerMock;
6566

6667
/**
67-
* @var Website|MockObject
68+
* @var Store|MockObject
6869
*/
69-
private $websiteMock;
70+
private $storeMock;
7071

7172
/**
7273
* @var UrlInterface|MockObject
@@ -106,8 +107,8 @@ protected function setUp(): void
106107
)->disableOriginalConstructor()
107108
->getMockForAbstractClass();
108109

109-
$this->websiteMock = $this->getMockBuilder(
110-
Website::class
110+
$this->storeMock= $this->getMockBuilder(
111+
Store::class
111112
)->onlyMethods(
112113
['getId']
113114
)->disableOriginalConstructor()
@@ -235,8 +236,8 @@ public function testGetSectionData()
235236
->method('getUrl')
236237
->willReturn('http://list.url');
237238

238-
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
239-
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
239+
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
240+
$this->storeMock->expects($this->any())->method('getId')->willReturn(1);
240241
$this->assertEquals(
241242
[
242243
'count' => $count,
@@ -265,7 +266,7 @@ public function testGetSectionData()
265266
'productScope' => null
266267
]
267268
],
268-
'websiteId' => 1
269+
'storeId' => 1
269270
],
270271
$this->model->getSectionData()
271272
);
@@ -286,16 +287,16 @@ public function testGetSectionDataNoItems()
286287
->method('getUrl')
287288
->willReturn('http://list.url');
288289

289-
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
290-
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
290+
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
291+
$this->storeMock->expects($this->any())->method('getId')->willReturn(1);
291292

292293
$this->assertEquals(
293294
[
294295
'count' => $count,
295296
'countCaption' => __('%1 items', $count),
296297
'listUrl' => 'http://list.url',
297298
'items' => [],
298-
'websiteId' => 1
299+
'storeId' => 1
299300
],
300301
$this->model->getSectionData()
301302
);
@@ -309,8 +310,8 @@ public function testGetSectionDataSingleItem()
309310
->method('getItemCount')
310311
->willReturn($count);
311312

312-
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
313-
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
313+
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
314+
$this->storeMock->expects($this->any())->method('getId')->willReturn(1);
314315

315316
$items = $this->prepareProductsWithCorrespondingMocks(
316317
[
@@ -345,7 +346,7 @@ public function testGetSectionDataSingleItem()
345346
'productScope' => null
346347
]
347348
],
348-
'websiteId' => 1
349+
'storeId' => 1
349350
],
350351
$this->model->getSectionData()
351352
);

app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ define([
3838
//Expired section names are reloaded on page load
3939
&& _.indexOf(customerData.getExpiredSectionNames(), 'compare-products') === -1
4040
&& window.checkout
41-
&& window.checkout.websiteId
42-
&& window.checkout.websiteId !== this.compareProducts().websiteId
41+
&& window.checkout.storeId
42+
&& window.checkout.storeId !== this.compareProducts().storeId
4343
) {
4444
//set count to 0 to prevent "compared products" blocks and count to show with wrong count and items
4545
this.compareProducts().count = 0;

dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/CompareTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
6-
76
namespace Magento\Catalog\Helper\Product;
87

98
use Magento\Catalog\Helper\Data;
@@ -142,7 +141,7 @@ public function testCalculate()
142141
$this->assertTrue($this->_helper->hasItems());
143142
$compareItems = $this->_helper->getItemCollection();
144143
$compareItems->clear();
145-
$session->unsCatalogCompareItemsCountPerWebsite();
144+
$session->unsCatalogCompareItemsCountPerStoreView();
146145
$this->assertFalse($this->_helper->hasItems());
147146
$this->assertEquals(0, $session->getCatalogCompareItemsCount());
148147
$this->storeManager->setCurrentStore(1);

0 commit comments

Comments
 (0)