Skip to content

Commit bd7f025

Browse files
author
Oleksii Korshenko
authored
Merge pull request #651 from magento-okapis/MAGETWO-58895-compare_products_2.1.x
Fixed issues: - MAGETWO-58895: [Backport] Customer is redirected to "Compare Products" Frontend page if tries to remove a Product from comparing - 2.1
2 parents aeb9504 + e4a017d commit bd7f025

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ public function getRemoveUrl()
228228
*/
229229
public function getPostDataRemove($product)
230230
{
231-
$listCleanUrl = $this->getEncodedUrl($this->_getUrl('catalog/product_compare'));
232231
$data = [
233-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $listCleanUrl,
234-
'product' => $product->getId()
232+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
233+
'product' => $product->getId(),
235234
];
236235
return $this->postHelper->getPostData($this->getRemoveUrl(), $data);
237236
}
@@ -253,9 +252,8 @@ public function getClearListUrl()
253252
*/
254253
public function getPostDataClearList()
255254
{
256-
$refererUrl = $this->_getRequest()->getServer('HTTP_REFERER');
257255
$params = [
258-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($refererUrl)
256+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
259257
];
260258
return $this->postHelper->getPostData($this->getClearListUrl(), $params);
261259
}

app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,13 @@ public function testGetPostDataRemove()
107107
//Data
108108
$productId = 1;
109109
$removeUrl = 'catalog/product_compare/remove';
110-
$compareListUrl = 'catalog/product_compare';
111110
$postParams = [
112-
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($compareListUrl), '+/=', '-_,'),
111+
Action::PARAM_NAME_URL_ENCODED => '',
113112
'product' => $productId
114113
];
115114

116115
//Verification
117-
$this->urlBuilder->expects($this->at(0))
118-
->method('getUrl')
119-
->with($compareListUrl)
120-
->will($this->returnValue($compareListUrl));
121-
$this->urlBuilder->expects($this->at(1))
116+
$this->urlBuilder->expects($this->once())
122117
->method('getUrl')
123118
->with($removeUrl)
124119
->will($this->returnValue($removeUrl));
@@ -153,18 +148,12 @@ public function testGetClearListUrl()
153148
public function testGetPostDataClearList()
154149
{
155150
//Data
156-
$refererUrl = 'home/';
157151
$clearUrl = 'catalog/product_compare/clear';
158152
$postParams = [
159-
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($refererUrl), '+/=', '-_,')
153+
Action::PARAM_NAME_URL_ENCODED => ''
160154
];
161155

162156
//Verification
163-
$this->request->expects($this->once())
164-
->method('getServer')
165-
->with('HTTP_REFERER')
166-
->will($this->returnValue($refererUrl));
167-
168157
$this->urlBuilder->expects($this->once())
169158
->method('getUrl')
170159
->with($clearUrl)

0 commit comments

Comments
 (0)