Skip to content

Commit

Permalink
Ensure option text attributes values are using their "parent" field p…
Browse files Browse the repository at this point in the history
…arameters for search usage : spellcheck, autocomplete, searchable, etc...
  • Loading branch information
romainruaud committed Sep 20, 2016
1 parent 5d9cb80 commit 16d3ef0
Showing 1 changed file with 9 additions and 11 deletions.
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

0 comments on commit 16d3ef0

Please sign in to comment.