File tree 4 files changed +40
-2
lines changed
Controller/Product/Compare
view/frontend/templates/messages
dev/tests/integration/testsuite/Magento/Catalog/Controller/Product
4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,14 @@ public function execute()
36
36
$ productName = $ this ->_objectManager ->get (
37
37
\Magento \Framework \Escaper::class
38
38
)->escapeHtml ($ product ->getName ());
39
- $ this ->messageManager ->addSuccess (__ ('You added product %1 to the comparison list. ' , $ productName ));
39
+ $ this ->messageManager ->addComplexSuccessMessage (
40
+ 'addCompareSuccessMessage ' ,
41
+ [
42
+ 'product_name ' => $ productName ,
43
+ 'compare_list_url ' => $ this ->_url ->getUrl ('catalog/product_compare ' )
44
+ ]
45
+ );
46
+
40
47
$ this ->_eventManager ->dispatch ('catalog_product_compare_add_product ' , ['product ' => $ product ]);
41
48
}
42
49
Original file line number Diff line number Diff line change 79
79
<argument name =" typeId" xsi : type =" string" >recently_compared_product</argument >
80
80
</arguments >
81
81
</virtualType >
82
+ <type name =" Magento\Framework\View\Element\Message\MessageConfigurationsPool" >
83
+ <arguments >
84
+ <argument name =" configurationsMap" xsi : type =" array" >
85
+ <item name =" addCompareSuccessMessage" xsi : type =" array" >
86
+ <item name =" renderer" xsi : type =" const" >\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item >
87
+ <item name =" data" xsi : type =" array" >
88
+ <item name =" template" xsi : type =" string" >Magento_Catalog::messages/addCompareSuccessMessage.phtml</item >
89
+ </item >
90
+ </item >
91
+ </argument >
92
+ </arguments >
93
+ </type >
82
94
<type name =" Magento\Catalog\Block\Product\View\Gallery" >
83
95
<arguments >
84
96
<argument name =" galleryImagesConfig" xsi : type =" array" >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ // @codingStandardsIgnoreFile
7
+ /** @var \Magento\Framework\View\Element\Template $block */
8
+ ?>
9
+ <?= $ block ->escapeHtml (__ (
10
+ 'You added product %1 to the <a href="%2">comparison list</a>. ' ,
11
+ $ block ->getData ('product_name ' ),
12
+ $ block ->getData ('compare_list_url ' )),
13
+ ['a ' ]
14
+ );
Original file line number Diff line number Diff line change @@ -48,7 +48,12 @@ public function testAddAction()
48
48
);
49
49
50
50
$ this ->assertSessionMessages (
51
- $ this ->equalTo (['You added product Simple Product 1 Name to the comparison list. ' ]),
51
+ $ this ->equalTo (
52
+ [
53
+ 'You added product Simple Product 1 Name to the ' .
54
+ '<a href="http://localhost/index.php/catalog/product_compare/">comparison list</a>. '
55
+ ]
56
+ ),
52
57
MessageInterface::TYPE_SUCCESS
53
58
);
54
59
You can’t perform that action at this time.
0 commit comments