diff --git a/app/code/Magento/Catalog/CustomerData/CompareProducts.php b/app/code/Magento/Catalog/CustomerData/CompareProducts.php
index bdac4dfde64d1..27e3ab2b0889a 100644
--- a/app/code/Magento/Catalog/CustomerData/CompareProducts.php
+++ b/app/code/Magento/Catalog/CustomerData/CompareProducts.php
@@ -63,7 +63,6 @@ public function getSectionData()
$count = $this->helper->getItemCount();
return [
'count' => $count,
- 'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count),
'listUrl' => $this->helper->getListUrl(),
'items' => $count ? $this->getItems() : [],
];
diff --git a/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php b/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
index 3a3656fe63b9e..8bb41a2875824 100644
--- a/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
@@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\CustomerData;
@@ -30,22 +29,22 @@ class CompareProductsTest extends TestCase
/**
* @var Compare|MockObject
*/
- private $helperMock;
+ private $objectManagerHelper;
/**
* @var Url|MockObject
*/
- private $productUrlMock;
+ private $helperMock;
/**
* @var Output|MockObject
*/
- private $outputHelperMock;
+ private $productUrlMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var Output|MockObject
*/
- private $objectManagerHelper;
+ private $outputHelperMock;
/**
* @var ScopeConfigInterface|MockObject
@@ -115,7 +114,7 @@ private function getItemCollectionMock(array $items) : MockObject
* @param array $dataSet
* @return array
*/
- private function prepareProductsWithCorrespondingMocks(array $dataSet) : array
+ private function prepareProductsWithCorrespondingMocks(array $dataSet):array
{
$items = [];
$urlMap = [];
@@ -171,7 +170,10 @@ private function getProductMock(array $data) : MockObject
return $product;
}
- public function testGetSectionData()
+ /**
+ * @return void
+ */
+ public function testGetSectionData():void
{
$dataSet = [
['id' => 1, 'name' => 'product#1'],
@@ -200,7 +202,6 @@ public function testGetSectionData()
$this->assertEquals(
[
'count' => $count,
- 'countCaption' => __('%1 items', $count),
'listUrl' => 'http://list.url',
'items' => [
[
@@ -230,7 +231,10 @@ public function testGetSectionData()
);
}
- public function testGetSectionDataNoItems()
+ /**
+ * @return void
+ */
+ public function testGetSectionDataNoItems():void
{
$count = 0;
@@ -248,7 +252,6 @@ public function testGetSectionDataNoItems()
$this->assertEquals(
[
'count' => $count,
- 'countCaption' => __('%1 items', $count),
'listUrl' => 'http://list.url',
'items' => []
],
@@ -256,7 +259,10 @@ public function testGetSectionDataNoItems()
);
}
- public function testGetSectionDataSingleItem()
+ /**
+ * @return void
+ */
+ public function testGetSectionDataSingleItem():void
{
$count = 1;
@@ -286,7 +292,6 @@ public function testGetSectionDataSingleItem()
$this->assertEquals(
[
'count' => 1,
- 'countCaption' => __('1 item'),
'listUrl' => 'http://list.url',
'items' => [
[
diff --git a/app/code/Magento/Catalog/ViewModel/Product/Compare/Sidebar.php b/app/code/Magento/Catalog/ViewModel/Product/Compare/Sidebar.php
new file mode 100644
index 0000000000000..0815803a694f0
--- /dev/null
+++ b/app/code/Magento/Catalog/ViewModel/Product/Compare/Sidebar.php
@@ -0,0 +1,39 @@
+compareHelper = $compareHelper;
+ }
+
+ /**
+ * Get parameters to clear compare list
+ *
+ * @return string
+ */
+ public function getClearCompareListParameters()
+ {
+ return $this->compareHelper->getPostDataClearList();
+ }
+}
diff --git a/app/code/Magento/Catalog/view/frontend/layout/default.xml b/app/code/Magento/Catalog/view/frontend/layout/default.xml
index 8f414724f51db..3906f5c4e0548 100644
--- a/app/code/Magento/Catalog/view/frontend/layout/default.xml
+++ b/app/code/Magento/Catalog/view/frontend/layout/default.xml
@@ -59,6 +59,7 @@
+