Skip to content

Commit 82eabce

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-1854' into ACP2E-1854
2 parents 2d0044a + e448bd4 commit 82eabce

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/SavingCustomAttributeValuesUsingUITest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setDropdownUseInLayeredNavigationNoResults">
5656
<argument name="useInLayeredNavigationValue" value="Filterable (with results)"/>
5757
</actionGroup>
58+
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInSearch}}" userInput="Yes" stepKey="selectIsSearchAble"/>
5859
<selectOption selector="{{AttributePropertiesSection.useInSearchResultsLayeredNavigation}}" userInput="Yes" stepKey="selectUseInLayeredNavigationOption"/>
5960
<click stepKey="saveAttribute" selector="{{AttributePropertiesSection.Save}}"/>
6061

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 (isset($result['is_filterable_in_search']) &&
25+
$result['is_filterable_in_search'] == '1' &&
26+
$result['is_searchable'] == '0'
27+
) {
28+
$result['is_filterable_in_search'] = '0';
29+
}
30+
31+
return $result;
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
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+

0 commit comments

Comments
 (0)