Skip to content

Commit 647880b

Browse files
committed
MC-25176: Storefront quick search leads to exception
1 parent 5067755 commit 647880b

File tree

4 files changed

+199
-98
lines changed

4 files changed

+199
-98
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class StaticField implements FieldProviderInterface
6262
*/
6363
private $fieldNameResolver;
6464

65+
/**
66+
* @var array
67+
*/
68+
private $excludedAttributes;
69+
6570
/**
6671
* @param Config $eavConfig
6772
* @param FieldTypeConverterInterface $fieldTypeConverter
@@ -70,6 +75,7 @@ class StaticField implements FieldProviderInterface
7075
* @param FieldIndexResolver $fieldIndexResolver
7176
* @param AttributeProvider $attributeAdapterProvider
7277
* @param FieldName\ResolverInterface|null $fieldNameResolver
78+
* @param array $excludedAttributes
7379
*/
7480
public function __construct(
7581
Config $eavConfig,
@@ -78,7 +84,8 @@ public function __construct(
7884
FieldTypeResolver $fieldTypeResolver,
7985
FieldIndexResolver $fieldIndexResolver,
8086
AttributeProvider $attributeAdapterProvider,
81-
FieldName\ResolverInterface $fieldNameResolver = null
87+
FieldName\ResolverInterface $fieldNameResolver = null,
88+
array $excludedAttributes = []
8289
) {
8390
$this->eavConfig = $eavConfig;
8491
$this->fieldTypeConverter = $fieldTypeConverter;
@@ -88,6 +95,7 @@ public function __construct(
8895
$this->attributeAdapterProvider = $attributeAdapterProvider;
8996
$this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance()
9097
->get(FieldName\ResolverInterface::class);
98+
$this->excludedAttributes = $excludedAttributes;
9199
}
92100

93101
/**
@@ -103,6 +111,9 @@ public function getFields(array $context = []): array
103111
$allAttributes = [];
104112

105113
foreach ($attributes as $attribute) {
114+
if (in_array($attribute->getAttributeCode(), $this->excludedAttributes, true)) {
115+
continue;
116+
}
106117
$attributeAdapter = $this->attributeAdapterProvider->getByAttributeCode($attribute->getAttributeCode());
107118
$fieldName = $this->fieldNameResolver->getFieldName($attributeAdapter);
108119

0 commit comments

Comments
 (0)