Skip to content

Commit cbe60d3

Browse files
rogerdzglo63652
authored andcommitted
fix 38200: Exception is not getting handled properly while adding a product to cart in the compare product page
1 parent c893121 commit cbe60d3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77
namespace Magento\Catalog\Controller\Product\Compare;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
109
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
1111
use Magento\Framework\Data\Form\FormKey\Validator;
1212
use Magento\Framework\View\Result\PageFactory;
1313

@@ -81,6 +81,8 @@ public function execute()
8181
$this->_catalogSession->setBeforeCompareUrl(
8282
$this->urlDecoder->decode($beforeUrl)
8383
);
84+
} else {
85+
$this->_catalogSession->unsBeforeCompareUrl();
8486
}
8587
return $this->resultPageFactory->create();
8688
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getSectionData()
7373
return [
7474
'count' => $count,
7575
'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count),
76-
'listUrl' => $this->helper->getListUrl(),
76+
'listUrl' => $this->helper->getListUrl(false),
7777
'items' => $count ? $this->getItems() : [],
7878
'websiteId' => $this->storeManager->getWebsite()->getId()
7979
];

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ public function __construct(
142142
/**
143143
* Retrieve compare list url
144144
*
145+
* @param bool $encodedUrl
145146
* @return string
146147
*/
147-
public function getListUrl()
148+
public function getListUrl($encodedUrl = true)
148149
{
149150
$params = [
150-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
151+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl ? $this->getEncodedUrl() : ''
151152
];
152153
return $this->_getUrl('catalog/product_compare', $params);
153154
}

0 commit comments

Comments
 (0)