Skip to content

Commit

Permalink
Merge pull request Smile-SA#116 from romainruaud/fix_option-attribute…
Browse files Browse the repository at this point in the history
…s-indexing

Ensure option text attributes values are using their "parent" field p…
  • Loading branch information
afoucret authored Sep 23, 2016
2 parents 5d9cb80 + 16d3ef0 commit 41e098b
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 41e098b

Please sign in to comment.