Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure option text attributes values are using their "parent" field p… #116

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down