File tree Expand file tree Collapse file tree 2 files changed +82
-1
lines changed
Ui/DataProvider/Product/Modifier Expand file tree Collapse file tree 2 files changed +82
-1
lines changed 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
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Catalog \Ui \DataProvider \Product \Modifier ;
9
+
10
+ use Magento \Framework \Escaper ;
11
+ use Magento \Ui \DataProvider \Modifier \ModifierInterface ;
12
+
13
+ /**
14
+ * Modify product listing attributes
15
+ */
16
+ class Attributes implements ModifierInterface
17
+ {
18
+ /**
19
+ * @var Escaper
20
+ */
21
+ private $ escaper ;
22
+
23
+ /**
24
+ * @var array
25
+ */
26
+ private $ escapeAttributes ;
27
+
28
+ /**
29
+ * @param Escaper $escaper
30
+ * @param array $escapeAttributes
31
+ */
32
+ public function __construct (
33
+ Escaper $ escaper ,
34
+ array $ escapeAttributes = []
35
+ ) {
36
+ $ this ->escaper = $ escaper ;
37
+ $ this ->escapeAttributes = $ escapeAttributes ;
38
+ }
39
+
40
+ /**
41
+ * @inheritdoc
42
+ */
43
+ public function modifyData (array $ data )
44
+ {
45
+ if (!empty ($ data ) && !empty ($ this ->escapeAttributes )) {
46
+ foreach ($ data ['items ' ] as &$ item ) {
47
+ foreach ($ this ->escapeAttributes as $ escapeAttribute ) {
48
+ if (isset ($ item [$ escapeAttribute ])) {
49
+ $ item [$ escapeAttribute ] = $ this ->escaper ->escapeHtml ($ item [$ escapeAttribute ]);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ return $ data ;
55
+ }
56
+
57
+ /**
58
+ * @inheritdoc
59
+ */
60
+ public function modifyMeta (array $ meta )
61
+ {
62
+ return $ meta ;
63
+ }
64
+ }
Original file line number Diff line number Diff line change 166
166
<argument name =" pool" xsi : type =" object" >Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool</argument >
167
167
</arguments >
168
168
</type >
169
- <virtualType name =" Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type =" Magento\Ui\DataProvider\Modifier\Pool" />
169
+ <virtualType name =" Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type =" Magento\Ui\DataProvider\Modifier\Pool" >
170
+ <arguments >
171
+ <argument name =" modifiers" xsi : type =" array" >
172
+ <item name =" attributes" xsi : type =" array" >
173
+ <item name =" class" xsi : type =" string" >Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes</item >
174
+ <item name =" sortOrder" xsi : type =" number" >10</item >
175
+ </item >
176
+ </argument >
177
+ </arguments >
178
+ </virtualType >
179
+ <type name =" Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes" >
180
+ <arguments >
181
+ <argument name =" escapeAttributes" xsi : type =" array" >
182
+ <item name =" name" xsi : type =" string" >name</item >
183
+ <item name =" sku" xsi : type =" string" >sku</item >
184
+ </argument >
185
+ </arguments >
186
+ </type >
170
187
<type name =" Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions" >
171
188
<arguments >
172
189
<argument name =" scopeName" xsi : type =" string" >product_form.product_form</argument >
You can’t perform that action at this time.
0 commit comments