Skip to content

Commit 7d6dff9

Browse files
committed
ACP2E-4249: Compare Products Count missmatch Issue for different stores
1 parent e885088 commit 7d6dff9

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
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/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;

0 commit comments

Comments
 (0)