Skip to content

Commit

Permalink
Merge pull request #651 from magento-okapis/MAGETWO-58895-compare_pro…
Browse files Browse the repository at this point in the history
…ducts_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
  • Loading branch information
Oleksii Korshenko authored Dec 12, 2016
2 parents aeb9504 + e4a017d commit bd7f025
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
8 changes: 3 additions & 5 deletions app/code/Magento/Catalog/Helper/Product/Compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,9 @@ public function getRemoveUrl()
*/
public function getPostDataRemove($product)
{
$listCleanUrl = $this->getEncodedUrl($this->_getUrl('catalog/product_compare'));
$data = [
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $listCleanUrl,
'product' => $product->getId()
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
'product' => $product->getId(),
];
return $this->postHelper->getPostData($this->getRemoveUrl(), $data);
}
Expand All @@ -253,9 +252,8 @@ public function getClearListUrl()
*/
public function getPostDataClearList()
{
$refererUrl = $this->_getRequest()->getServer('HTTP_REFERER');
$params = [
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($refererUrl)
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
];
return $this->postHelper->getPostData($this->getClearListUrl(), $params);
}
Expand Down
17 changes: 3 additions & 14 deletions app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,13 @@ public function testGetPostDataRemove()
//Data
$productId = 1;
$removeUrl = 'catalog/product_compare/remove';
$compareListUrl = 'catalog/product_compare';
$postParams = [
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($compareListUrl), '+/=', '-_,'),
Action::PARAM_NAME_URL_ENCODED => '',
'product' => $productId
];

//Verification
$this->urlBuilder->expects($this->at(0))
->method('getUrl')
->with($compareListUrl)
->will($this->returnValue($compareListUrl));
$this->urlBuilder->expects($this->at(1))
$this->urlBuilder->expects($this->once())
->method('getUrl')
->with($removeUrl)
->will($this->returnValue($removeUrl));
Expand Down Expand Up @@ -153,18 +148,12 @@ public function testGetClearListUrl()
public function testGetPostDataClearList()
{
//Data
$refererUrl = 'home/';
$clearUrl = 'catalog/product_compare/clear';
$postParams = [
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($refererUrl), '+/=', '-_,')
Action::PARAM_NAME_URL_ENCODED => ''
];

//Verification
$this->request->expects($this->once())
->method('getServer')
->with('HTTP_REFERER')
->will($this->returnValue($refererUrl));

$this->urlBuilder->expects($this->once())
->method('getUrl')
->with($clearUrl)
Expand Down

0 comments on commit bd7f025

Please sign in to comment.