9
9
use Magento \Framework \App \Config \ScopeConfigInterface ;
10
10
use Magento \Framework \App \ObjectManager ;
11
11
use Magento \Framework \Exception \LocalizedException ;
12
+ use Magento \Framework \UrlInterface ;
12
13
use Magento \Store \Model \StoreManagerInterface ;
13
14
14
15
/**
@@ -43,25 +44,33 @@ class CompareProducts implements SectionSourceInterface
43
44
*/
44
45
private $ storeManager ;
45
46
47
+ /**
48
+ * @var UrlInterface
49
+ */
50
+ private $ urlBuilder ;
51
+
46
52
/**
47
53
* @param \Magento\Catalog\Helper\Product\Compare $helper
48
54
* @param \Magento\Catalog\Model\Product\Url $productUrl
49
55
* @param \Magento\Catalog\Helper\Output $outputHelper
50
56
* @param ScopeConfigInterface|null $scopeConfig
51
57
* @param StoreManagerInterface|null $storeManager
58
+ * @param UrlInterface|null $urlBuilder
52
59
*/
53
60
public function __construct (
54
61
\Magento \Catalog \Helper \Product \Compare $ helper ,
55
62
\Magento \Catalog \Model \Product \Url $ productUrl ,
56
63
\Magento \Catalog \Helper \Output $ outputHelper ,
57
64
?ScopeConfigInterface $ scopeConfig = null ,
58
- ?StoreManagerInterface $ storeManager = null
65
+ ?StoreManagerInterface $ storeManager = null ,
66
+ ?UrlInterface $ urlBuilder = null
59
67
) {
60
68
$ this ->helper = $ helper ;
61
69
$ this ->productUrl = $ productUrl ;
62
70
$ this ->outputHelper = $ outputHelper ;
63
71
$ this ->scopeConfig = $ scopeConfig ?? ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
64
72
$ this ->storeManager = $ storeManager ?? ObjectManager::getInstance ()->get (StoreManagerInterface::class);
73
+ $ this ->urlBuilder = $ urlBuilder ?? ObjectManager::getInstance ()->get (UrlInterface::class);
65
74
}
66
75
67
76
/**
@@ -73,7 +82,7 @@ public function getSectionData()
73
82
return [
74
83
'count ' => $ count ,
75
84
'countCaption ' => $ count == 1 ? __ ('1 item ' ) : __ ('%1 items ' , $ count ),
76
- 'listUrl ' => $ this ->helper -> getListUrl ( ),
85
+ 'listUrl ' => $ this ->urlBuilder -> getUrl ( ' catalog/product_compare ' ),
77
86
'items ' => $ count ? $ this ->getItems () : [],
78
87
'websiteId ' => $ this ->storeManager ->getWebsite ()->getId ()
79
88
];
0 commit comments