Skip to content

Commit 262d6b2

Browse files
committed
Merge remote-tracking branch 'origin/MC-30229' into 2.4-develop-pr10
2 parents 9851872 + fea7701 commit 262d6b2

File tree

5 files changed

+3
-75
lines changed

5 files changed

+3
-75
lines changed

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\View\Result\PageFactory;
1313

1414
/**
15+
* View products compare in frontend
16+
*
1517
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1618
*/
1719
class Index extends \Magento\Catalog\Controller\Product\Compare implements HttpGetActionInterface
@@ -74,23 +76,12 @@ public function __construct(
7476
*/
7577
public function execute()
7678
{
77-
$items = $this->getRequest()->getParam('items');
78-
7979
$beforeUrl = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED);
8080
if ($beforeUrl) {
8181
$this->_catalogSession->setBeforeCompareUrl(
8282
$this->urlDecoder->decode($beforeUrl)
8383
);
8484
}
85-
86-
if ($items) {
87-
$items = explode(',', $items);
88-
/** @var \Magento\Catalog\Model\Product\Compare\ListCompare $list */
89-
$list = $this->_catalogProductCompareList;
90-
$list->addProducts($items);
91-
$resultRedirect = $this->resultRedirectFactory->create();
92-
return $resultRedirect->setPath('*/*/*');
93-
}
9485
return $this->resultPageFactory->create();
9586
}
9687
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @api
1515
* @SuppressWarnings(PHPMD.LongVariable)
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1718
* @since 100.0.2
1819
*/
1920
class Compare extends \Magento\Framework\Url\Helper\Data
@@ -145,16 +146,9 @@ public function __construct(
145146
*/
146147
public function getListUrl()
147148
{
148-
$itemIds = [];
149-
foreach ($this->getItemCollection() as $item) {
150-
$itemIds[] = $item->getId();
151-
}
152-
153149
$params = [
154-
'items' => implode(',', $itemIds),
155150
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
156151
];
157-
158152
return $this->_getUrl('catalog/product_compare', $params);
159153
}
160154

app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public function testExecute()
129129
->method('getParam')
130130
->willReturnMap(
131131
[
132-
['items', null, null],
133132
['uenc', null, $beforeUrl],
134133
]
135134
);
@@ -141,34 +140,7 @@ public function testExecute()
141140
->method('setBeforeCompareUrl')
142141
->with($beforeUrl . '1')
143142
->willReturnSelf();
144-
$this->listCompareMock->expects($this->never())->method('addProducts');
145143
$this->redirectFactoryMock->expects($this->never())->method('create');
146144
$this->index->execute();
147145
}
148-
149-
public function testExecuteWithItems()
150-
{
151-
$this->request->expects($this->any())
152-
->method('getParam')
153-
->willReturnMap(
154-
[
155-
['items', null, '1,2,3'],
156-
['uenc', null, null],
157-
]
158-
);
159-
$this->decoderMock->expects($this->never())->method('decode');
160-
$this->catalogSession->expects($this->never())->method('setBeforeCompareUrl');
161-
162-
$this->listCompareMock->expects($this->once())
163-
->method('addProducts')
164-
->with([1, 2, 3]);
165-
$redirect = $this->createPartialMock(\Magento\Framework\Controller\Result\Redirect::class, ['setPath']);
166-
$redirect->expects($this->once())
167-
->method('setPath')
168-
->with('*/*/*');
169-
$this->redirectFactoryMock->expects($this->once())
170-
->method('create')
171-
->willReturn($redirect);
172-
$this->index->execute();
173-
}
174146
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,6 @@ public function testAddActionForDisabledProduct(): void
9696
$this->_assertCompareListEquals([]);
9797
}
9898

99-
/**
100-
* Test comparing a product.
101-
*
102-
* @throws \Magento\Framework\Exception\NoSuchEntityException
103-
*/
104-
public function testIndexActionAddProducts()
105-
{
106-
$this->_requireVisitorWithNoProducts();
107-
$product = $this->productRepository->get('simple_product_2');
108-
$this->dispatch('catalog/product_compare/index/items/' . $product->getEntityId());
109-
110-
$this->assertRedirect($this->stringStartsWith('http://localhost/index.php/catalog/product_compare/index/'));
111-
112-
$this->_assertCompareListEquals([$product->getEntityId()]);
113-
}
114-
11599
/**
116100
* Test removing a product from compare list.
117101
*

dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/CompareTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,11 @@ protected function setUp()
2323
$this->_helper = $this->_objectManager->get(\Magento\Catalog\Helper\Product\Compare::class);
2424
}
2525

26-
/**
27-
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
28-
* @magentoDbIsolation disabled
29-
*/
3026
public function testGetListUrl()
3127
{
3228
/** @var $empty \Magento\Catalog\Helper\Product\Compare */
3329
$empty = $this->_objectManager->create(\Magento\Catalog\Helper\Product\Compare::class);
3430
$this->assertContains('/catalog/product_compare/index/', $empty->getListUrl());
35-
36-
$this->_populateCompareList();
37-
$productRepository = $this->_objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
38-
$id1 = $productRepository->get('simple1')->getId();
39-
$id2 = $productRepository->get('simple2')->getId();
40-
$this->assertRegExp(
41-
'#/catalog/product_compare/index/items/(?:' . $id1 . '%2C' . $id2 . '|' . $id2 . '%2C' . $id1. ')/#',
42-
$this->_helper->getListUrl()
43-
);
4431
}
4532

4633
public function testGetAddUrl()

0 commit comments

Comments
 (0)