From 16d3ef0155ec44ab2f5b1c031c3eab09911f40ca Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Thu, 15 Sep 2016 11:48:41 +0200 Subject: [PATCH] Ensure option text attributes values are using their "parent" field parameters for search usage : spellcheck, autocomplete, searchable, etc... --- .../Datasource/AbstractAttributeData.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php b/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php index 12dc3c04d..9c6e97d4f 100644 --- a/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php +++ b/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php @@ -167,28 +167,26 @@ private function canIndexAttribute(AttributeInterface $attribute) * * @param AttributeInterface $attribute Entity attribute. * - * @return \Smile\ElasticsuiteCatalog\Model\Catalog\Indexer\Fulltext\Datasource\AbstractAttributeData + * @return \Smile\ElasticsuiteCatalog\Model\Eav\Indexer\Fulltext\Datasource\AbstractAttributeData */ private function initField(AttributeInterface $attribute) { $fieldName = $attribute->getAttributeCode(); - $fieldType = $this->attributeHelper->getFieldType($attribute); - $fieldConfig = $this->attributeHelper->getMappingFieldOptions($attribute); if ($attribute->usesSource()) { - $fieldConfig = $this->attributeHelper->getMappingFieldOptions($attribute); - $fieldConfig['is_searchable'] = false; - $fieldConfig['is_used_in_spellcheck'] = false; - $fieldConfig['is_used_in_autocomplete'] = false; - $fieldOptions = ['name' => $fieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig]; - $this->fields[$fieldName] = $this->fieldFactory->create($fieldOptions); - $fieldName = $this->attributeHelper->getOptionTextFieldName($fieldName); + $optionFieldName = $this->attributeHelper->getOptionTextFieldName($fieldName); $fieldType = 'string'; + $fieldOptions = ['name' => $optionFieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig]; + $this->fields[$optionFieldName] = $this->fieldFactory->create($fieldOptions); - $fieldConfig['is_searchable'] = true; + // Reset parent field values : only the option text field should be used for spellcheck and autocomplete. + $fieldConfig['is_used_in_spellcheck'] = false; + $fieldConfig['is_used_in_autocomplete'] = false; + $fieldConfig['is_searchable'] = false; } + $fieldType = $this->attributeHelper->getFieldType($attribute); $fieldOptions = ['name' => $fieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig]; $this->fields[$fieldName] = $this->fieldFactory->create($fieldOptions);