Skip to content

Commit 4a94174

Browse files
committed
Merge remote-tracking branch 'origin/MC-17050' into 2.3.2-develop-pr55
2 parents 0ee665a + eb5eb21 commit 4a94174

File tree

8 files changed

+66
-57
lines changed

8 files changed

+66
-57
lines changed

app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public function __construct(ConverterInterface $fieldTypeConverter, $integerType
4545
public function getFieldType(AttributeAdapter $attribute): ?string
4646
{
4747
if (in_array($attribute->getAttributeCode(), $this->integerTypeAttributes, true)
48-
|| (($attribute->isIntegerType() || $attribute->isBooleanType())
49-
&& !$attribute->isUserDefined())
48+
|| ($attribute->isIntegerType() || $attribute->isBooleanType())
5049
) {
5150
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT);
5251
}

app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public function __construct(ConverterInterface $fieldTypeConverter)
3737
*/
3838
public function getFieldType(AttributeAdapter $attribute): ?string
3939
{
40-
if ($attribute->isComplexType()
41-
|| (!$attribute->isSearchable() && !$attribute->isAlwaysIndexable() && $attribute->isFilterable())
40+
if (($attribute->isComplexType()
41+
|| (!$attribute->isSearchable() && !$attribute->isAlwaysIndexable() && $attribute->isFilterable()))
42+
&& !$attribute->isBooleanType()
4243
) {
4344
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_KEYWORD);
4445
}

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ public function isSortable(): bool
159159
/**
160160
* Check if attribute is defined by user.
161161
*
162-
* @return string
162+
* @return bool|null
163163
*/
164-
public function isUserDefined(): string
164+
public function isUserDefined()
165165
{
166166
return $this->getAttribute()->getIsUserDefined();
167167
}

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public function __construct(ConverterInterface $fieldTypeConverter)
3737
*/
3838
public function getFieldType(AttributeAdapter $attribute): ?string
3939
{
40-
if (($attribute->isIntegerType() || $attribute->isBooleanType())
41-
&& !$attribute->isUserDefined()
42-
) {
40+
if ($attribute->isIntegerType() || $attribute->isBooleanType()) {
4341
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT);
4442
}
4543

app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ protected function setUp()
5353

5454
/**
5555
* @dataProvider getFieldTypeProvider
56-
* @param $attributeCode
57-
* @param $isIntegerType
58-
* @param $isBooleanType
59-
* @param $isUserDefined
60-
* @param $expected
56+
* @param string $attributeCode
57+
* @param bool $isIntegerType
58+
* @param bool $isBooleanType
59+
* @param string $expected
6160
* @return void
6261
*/
63-
public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected)
64-
{
62+
public function testGetFieldType(
63+
string $attributeCode,
64+
bool $isIntegerType,
65+
bool $isBooleanType,
66+
string $expected
67+
): void {
6568
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
6669
->disableOriginalConstructor()
6770
->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined'])
@@ -75,9 +78,6 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
7578
$attributeMock->expects($this->any())
7679
->method('isBooleanType')
7780
->willReturn($isBooleanType);
78-
$attributeMock->expects($this->any())
79-
->method('isUserDefined')
80-
->willReturn($isUserDefined);
8181
$this->fieldTypeConverter->expects($this->any())
8282
->method('convert')
8383
->willReturn('something');
@@ -94,12 +94,12 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
9494
public function getFieldTypeProvider()
9595
{
9696
return [
97-
['category_ids', true, true, true, 'something'],
98-
['category_ids', false, false, false, 'something'],
99-
['type', true, false, false, 'something'],
100-
['type', false, true, false, 'something'],
101-
['type', true, true, true, ''],
102-
['type', false, false, true, ''],
97+
['category_ids', true, true, 'something'],
98+
['category_ids', false, false, 'something'],
99+
['type', true, false, 'something'],
100+
['type', false, true, 'something'],
101+
['type', true, true, 'something'],
102+
['type', false, false, ''],
103103
];
104104
}
105105
}

app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,25 @@ protected function setUp()
5353

5454
/**
5555
* @dataProvider getFieldTypeProvider
56-
* @param $isComplexType
57-
* @param $isSearchable
58-
* @param $isAlwaysIndexable
59-
* @param $isFilterable
60-
* @param $expected
56+
* @param bool $isComplexType
57+
* @param bool $isSearchable
58+
* @param bool $isAlwaysIndexable
59+
* @param bool $isFilterable
60+
* @param bool $isBoolean
61+
* @param string $expected
6162
* @return void
6263
*/
63-
public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexable, $isFilterable, $expected)
64-
{
64+
public function testGetFieldType(
65+
bool $isComplexType,
66+
bool $isSearchable,
67+
bool $isAlwaysIndexable,
68+
bool $isFilterable,
69+
bool $isBoolean,
70+
string $expected
71+
): void {
6572
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
6673
->disableOriginalConstructor()
67-
->setMethods(['isComplexType', 'isSearchable', 'isAlwaysIndexable', 'isFilterable'])
74+
->setMethods(['isComplexType', 'isSearchable', 'isAlwaysIndexable', 'isFilterable', 'isBooleanType'])
6875
->getMock();
6976
$attributeMock->expects($this->any())
7077
->method('isComplexType')
@@ -78,6 +85,9 @@ public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexab
7885
$attributeMock->expects($this->any())
7986
->method('isFilterable')
8087
->willReturn($isFilterable);
88+
$attributeMock->expects($this->any())
89+
->method('isBooleanType')
90+
->willReturn($isBoolean);
8191
$this->fieldTypeConverter->expects($this->any())
8292
->method('convert')
8393
->willReturn('something');
@@ -94,13 +104,14 @@ public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexab
94104
public function getFieldTypeProvider()
95105
{
96106
return [
97-
[true, true, true, true, 'something'],
98-
[true, false, false, false, 'something'],
99-
[true, false, false, true, 'something'],
100-
[false, false, false, true, 'something'],
101-
[false, false, false, false, ''],
102-
[false, false, true, false, ''],
103-
[false, true, false, false, ''],
107+
[true, true, true, true, false, 'something'],
108+
[true, false, false, false, false, 'something'],
109+
[true, false, false, true, false, 'something'],
110+
[false, false, false, true, false, 'something'],
111+
[false, false, false, false, false, ''],
112+
[false, false, true, false, false, ''],
113+
[false, true, false, false, false, ''],
114+
[true, true, true, true, true, ''],
104115
];
105116
}
106117
}

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,18 @@ protected function setUp()
5252

5353
/**
5454
* @dataProvider getFieldTypeProvider
55-
* @param $attributeCode
56-
* @param $isIntegerType
57-
* @param $isBooleanType
58-
* @param $isUserDefined
59-
* @param $expected
55+
* @param string $attributeCode
56+
* @param bool $isIntegerType
57+
* @param bool $isBooleanType
58+
* @param string|null $expected
6059
* @return void
6160
*/
62-
public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected)
63-
{
61+
public function testGetFieldType(
62+
string $attributeCode,
63+
bool $isIntegerType,
64+
bool $isBooleanType,
65+
$expected
66+
): void {
6467
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
6568
->disableOriginalConstructor()
6669
->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined'])
@@ -74,9 +77,6 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
7477
$attributeMock->expects($this->any())
7578
->method('isBooleanType')
7679
->willReturn($isBooleanType);
77-
$attributeMock->expects($this->any())
78-
->method('isUserDefined')
79-
->willReturn($isUserDefined);
8080
$this->fieldTypeConverter->expects($this->any())
8181
->method('convert')
8282
->willReturn('something');
@@ -93,12 +93,12 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
9393
public function getFieldTypeProvider()
9494
{
9595
return [
96-
['category_ids', true, true, true, null],
97-
['category_ids', false, false, false, null],
98-
['type', true, false, false, 'something'],
99-
['type', false, true, false, 'something'],
100-
['type', true, true, true, ''],
101-
['type', false, false, true, ''],
96+
['category_ids', true, true, 'something'],
97+
['category_ids', false, false, null],
98+
['type', true, false, 'something'],
99+
['type', false, true, 'something'],
100+
['type', true, true, 'something'],
101+
['type', false, false, ''],
102102
];
103103
}
104104
}

app/code/Magento/Elasticsearch/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@
478478
<argument name="indexTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter</argument>
479479
<argument name="fieldIndexResolver" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver</argument>
480480
<argument name="fieldTypeResolver" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver</argument>
481-
<argument name="fieldNameResolver" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface</argument>
481+
<argument name="fieldNameResolver" xsi:type="object">elasticsearch5FieldNameResolver</argument>
482482
</arguments>
483483
</virtualType>
484484
<virtualType name="elasticsearch5DynamicFieldProvider" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\DynamicField">

0 commit comments

Comments
 (0)