File tree Expand file tree Collapse file tree 5 files changed +62
-10
lines changed
code/Magento/LayeredNavigation
design/frontend/Magento/luma/Magento_LayeredNavigation/templates/layer Expand file tree Collapse file tree 5 files changed +62
-10
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /************************************************************************
3
+ *
4
+ * Copyright 2024 Adobe
5
+ * All Rights Reserved.
6
+ *
7
+ * NOTICE: All information contained herein is, and remains
8
+ * the property of Adobe and its suppliers, if any. The intellectual
9
+ * and technical concepts contained herein are proprietary to Adobe
10
+ * and its suppliers and are protected by all applicable intellectual
11
+ * property laws, including trade secret and copyright laws.
12
+ * Dissemination of this information or reproduction of this material
13
+ * is strictly forbidden unless prior written permission is obtained
14
+ * from Adobe.
15
+ * ************************************************************************
16
+ */
17
+
18
+ namespace Magento \LayeredNavigation \ViewModel \Layer ;
19
+
20
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
21
+ use Magento \LayeredNavigation \Block \Navigation \State as StateBlock ;
22
+
23
+ class State implements ArgumentInterface
24
+ {
25
+ /**
26
+ * @param StateBlock $block
27
+ */
28
+ public function __construct (private StateBlock $ block )
29
+ {
30
+ }
31
+
32
+ /**
33
+ * Skip string value '0' to be filtered against stripTags
34
+ *
35
+ * @param string $data
36
+ * @return string
37
+ */
38
+ public function stripTags (string $ data ): string
39
+ {
40
+ if ($ data !== '0 ' ) {
41
+ return $ this ->block ->stripTags ($ data );
42
+ }
43
+
44
+ return $ data ;
45
+ }
46
+ }
Original file line number Diff line number Diff line change 10
10
<attribute name =" class" value =" page-with-filter" />
11
11
<referenceContainer name =" sidebar.main" >
12
12
<block class =" Magento\LayeredNavigation\Block\Navigation\Category" name =" catalog.leftnav" before =" -" template =" Magento_LayeredNavigation::layer/view.phtml" >
13
- <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalog.navigation.state" as =" state" />
13
+ <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalog.navigation.state" as =" state" >
14
+ <arguments >
15
+ <argument name =" view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\State</argument >
16
+ </arguments >
17
+ </block >
14
18
<block class =" Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name =" catalog.navigation.renderer" as =" renderer" template =" Magento_LayeredNavigation::layer/filter.phtml" >
15
19
<arguments >
16
20
<argument name =" product_layer_view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\Filter</argument >
Original file line number Diff line number Diff line change 10
10
<attribute name =" class" value =" page-with-filter" />
11
11
<referenceContainer name =" sidebar.main" >
12
12
<block class =" Magento\LayeredNavigation\Block\Navigation\Search" name =" catalogsearch.leftnav" before =" -" template =" Magento_LayeredNavigation::layer/view.phtml" >
13
- <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalogsearch.navigation.state" as =" state" />
13
+ <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalogsearch.navigation.state" as =" state" >
14
+ <arguments >
15
+ <argument name =" view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\State</argument >
16
+ </arguments >
17
+ </block >
14
18
<block class =" Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name =" catalogsearch.navigation.renderer" as =" renderer" template =" Magento_LayeredNavigation::layer/filter.phtml" >
15
19
<arguments >
16
20
<argument name =" product_layer_view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\Filter</argument >
Original file line number Diff line number Diff line change 10
10
*
11
11
* @var $escaper \Magento\Framework\Escaper
12
12
* @var $block \Magento\LayeredNavigation\Block\Navigation\State
13
+ * @var $viewModel \Magento\LayeredNavigation\ViewModel\Layer\State
13
14
*/
15
+ $ viewModel = $ block ->getViewModel ();
14
16
?>
15
17
<?php $ _filters = $ block ->getActiveFilters () ?>
16
18
<?php if (!empty ($ _filters )): ?>
24
26
<?php foreach ($ _filters as $ _filter ): ?>
25
27
<li class="item">
26
28
<span class="filter-label"><?= $ escaper ->escapeHtml (__ ($ _filter ->getName ())) ?> </span>
27
- <span class="filter-value">
28
- <?= ((string )$ _filter ->getLabel () === "0 " ) ? $ escaper ->escapeHtml ($ _filter ->getLabel ()) :
29
- $ escaper ->escapeHtml ($ block ->stripTags ($ _filter ->getLabel ())) ?>
30
- </span>
29
+ <span class="filter-value"><?= $ escaper ->escapeHtml ($ viewModel ->stripTags ($ _filter ->getLabel ())) ?> </span>
31
30
<?php
32
31
$ clearLinkUrl = $ _filter ->getClearLinkUrl ();
33
32
$ currentFilterName = $ escaper ->escapeHtmlAttr (
Original file line number Diff line number Diff line change 12
12
*
13
13
* @var $escaper \Magento\Framework\Escaper
14
14
* @var $block \Magento\LayeredNavigation\Block\Navigation\State
15
+ * @var $viewModel \Magento\LayeredNavigation\ViewModel\Layer\State
15
16
*/
17
+ $ viewModel = $ block ->getViewModel ();
16
18
?>
17
19
<?php $ _filters = $ block ->getActiveFilters () ?>
18
20
<?php if (!empty ($ _filters )): ?>
26
28
<?php foreach ($ _filters as $ _filter ): ?>
27
29
<li class="item">
28
30
<span class="filter-label"><?= $ escaper ->escapeHtml (__ ($ _filter ->getName ())) ?> </span>
29
- <span class="filter-value">
30
- <?= ((string )$ _filter ->getLabel () === "0 " ) ? $ escaper ->escapeHtml ($ _filter ->getLabel ()) :
31
- $ escaper ->escapeHtml ($ block ->stripTags ($ _filter ->getLabel ())) ?>
32
- </span>
31
+ <span class="filter-value"><?= $ escaper ->escapeHtml ($ viewModel ->stripTags ($ _filter ->getLabel ())) ?> </span>
33
32
<?php
34
33
$ clearLinkUrl = $ _filter ->getClearLinkUrl ();
35
34
$ currentFilterName = $ escaper ->escapeHtmlAttr (__ ($ _filter ->getName ()) . " " . $ block ->stripTags ($ _filter ->getLabel ()));
You can’t perform that action at this time.
0 commit comments