File tree Expand file tree Collapse file tree 3 files changed +80
-0
lines changed
app/code/Magento/LayeredNavigation Expand file tree Collapse file tree 3 files changed +80
-0
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 \LayeredNavigation \Plugin \Save ;
9
+
10
+ use Magento \Catalog \Model \Product \Attribute \Frontend \Inputtype \Presentation ;
11
+
12
+ class AdjustAttributeSearchable
13
+ {
14
+ /**
15
+ * Change attribute value if the filterable option is not enabled
16
+ *
17
+ * @param Presentation $subject
18
+ * @param array $result
19
+ * @return array
20
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
21
+ */
22
+ public function afterConvertPresentationDataToInputType (Presentation $ subject , array $ result ): array
23
+ {
24
+ if (
25
+ isset ($ result ['is_filterable_in_search ' ]) &&
26
+ $ result ['is_filterable_in_search ' ] == '1 ' &&
27
+ $ result ['is_searchable ' ] == '0 '
28
+ ) {
29
+ $ result ['is_filterable_in_search ' ] = '0 ' ;
30
+ }
31
+
32
+ return $ result ;
33
+ }
34
+ }
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
+
7
+ declare (strict_types=1 );
8
+
9
+ namespace Magento \LayeredNavigation \Test \Unit \Plugin \Save ;
10
+
11
+ use Magento \Catalog \Model \Product \Attribute \Frontend \Inputtype \Presentation ;
12
+ use Magento \LayeredNavigation \Plugin \Save \AdjustAttributeSearchable ;
13
+ use PHPUnit \Framework \TestCase ;
14
+
15
+ class AdjustAttributeSearchableTest extends TestCase
16
+ {
17
+ /**
18
+ * @return void
19
+ */
20
+ public function testAfterConvertPresentationDataToInputType (): void
21
+ {
22
+ $ presentation = $ this ->createMock (Presentation::class);
23
+ $ result = [
24
+ 'is_filterable_in_search ' => '1 ' ,
25
+ 'is_searchable ' => '0 '
26
+ ];
27
+ $ interceptor = new AdjustAttributeSearchable ();
28
+ $ this ->assertSame (
29
+ ['is_filterable_in_search ' => '0 ' , 'is_searchable ' => '0 ' ],
30
+ $ interceptor ->afterConvertPresentationDataToInputType ($ presentation , $ result )
31
+ );
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © Magento, Inc. All rights reserved.
5
+ * See COPYING.txt for license details.
6
+ */
7
+ -->
8
+ <config >
9
+ <type name =" Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation" >
10
+ <plugin name =" adjust_searchable_attribute_values" type =" Magento\LayeredNavigation\Plugin\Save\AdjustAttributeSearchable" sortOrder =" 1" disabled =" false" />
11
+ </type >
12
+ </config >
13
+
You can’t perform that action at this time.
0 commit comments