Skip to content

Commit b041690

Browse files
rogerdzglo63652
authored andcommitted
update code
1 parent 60dc40b commit b041690

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

app/code/Magento/Catalog/Controller/Product/Compare/Index.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ public function execute()
7878
{
7979
$beforeUrl = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED);
8080
if ($beforeUrl) {
81-
$beforeUrl = $this->urlDecoder->decode($beforeUrl);
82-
if(strpos((string)$beforeUrl, "customer/section/load") == 0){
83-
$this->_catalogSession->setBeforeCompareUrl(
84-
$beforeUrl
85-
);
86-
} else {
87-
$this->_catalogSession->unsBeforeCompareUrl();
88-
}
81+
$this->_catalogSession->setBeforeCompareUrl(
82+
$this->urlDecoder->decode($beforeUrl)
83+
);
84+
} else {
85+
$this->_catalogSession->unsBeforeCompareUrl();
8986
}
9087
return $this->resultPageFactory->create();
9188
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\UrlInterface;
1213
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
@@ -43,25 +44,33 @@ class CompareProducts implements SectionSourceInterface
4344
*/
4445
private $storeManager;
4546

47+
/**
48+
* @var UrlInterface
49+
*/
50+
private $urlBuilder;
51+
4652
/**
4753
* @param \Magento\Catalog\Helper\Product\Compare $helper
4854
* @param \Magento\Catalog\Model\Product\Url $productUrl
4955
* @param \Magento\Catalog\Helper\Output $outputHelper
5056
* @param ScopeConfigInterface|null $scopeConfig
5157
* @param StoreManagerInterface|null $storeManager
58+
* @param UrlInterface|null $urlBuilder
5259
*/
5360
public function __construct(
5461
\Magento\Catalog\Helper\Product\Compare $helper,
5562
\Magento\Catalog\Model\Product\Url $productUrl,
5663
\Magento\Catalog\Helper\Output $outputHelper,
5764
?ScopeConfigInterface $scopeConfig = null,
58-
?StoreManagerInterface $storeManager = null
65+
?StoreManagerInterface $storeManager = null,
66+
?UrlInterface $urlBuilder = null
5967
) {
6068
$this->helper = $helper;
6169
$this->productUrl = $productUrl;
6270
$this->outputHelper = $outputHelper;
6371
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
6472
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
73+
$this->urlBuilder = $urlBuilder ?? ObjectManager::getInstance()->get(UrlInterface::class);
6574
}
6675

6776
/**
@@ -73,7 +82,7 @@ public function getSectionData()
7382
return [
7483
'count' => $count,
7584
'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count),
76-
'listUrl' => $this->helper->getListUrl(),
85+
'listUrl' => $this->urlBuilder->getUrl('catalog/product_compare'),
7786
'items' => $count ? $this->getItems() : [],
7887
'websiteId' => $this->storeManager->getWebsite()->getId()
7988
];

0 commit comments

Comments
 (0)