private function initField(AttributeInterface $attribute)
    {
        $fieldName = $attribute->getAttributeCode();
        $fieldConfig = $this->attributeHelper->getMappingFieldOptions($attribute);

        if ($attribute->usesSource()) {
            $optionFieldName = $this->attributeHelper->getOptionTextFieldName($fieldName);
            $fieldType = FieldInterface::FIELD_TYPE_TEXT;
            $fieldOptions = ['name' => $optionFieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig];
            $this->fields[$optionFieldName] = $this->fieldFactory->create($fieldOptions);

            // Reset parent field values : only the option text field should be used for spellcheck and autocomplete.
            $fieldConfig['is_used_in_spellcheck'] = false;
            $fieldConfig['is_searchable'] = false;
        }

        $fieldType    = $this->attributeHelper->getFieldType($attribute);
        $fieldOptions = ['name' => $fieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig];

        $this->fields[$fieldName] = $this->fieldFactory->create($fieldOptions);

        return $this;
    }
private function initField(AttributeInterface $attribute)
    {
        $fieldName = $attribute->getAttributeCode();
        $fieldConfig = $this->attributeHelper->getMappingFieldOptions($attribute);

        if ($attribute->usesSource()) {
            $optionFieldName = $this->attributeHelper->getOptionTextFieldName($fieldName);
            $fieldType = FieldInterface::FIELD_TYPE_TEXT;
            $fieldOptions = ['name' => $optionFieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig];
            $this->fields[$optionFieldName] = $this->fieldFactory->create($fieldOptions);

            // Reset parent field values : only the option text field should be used for spellcheck and autocomplete.
            $fieldConfig['is_used_in_spellcheck'] = false;
            $fieldConfig['is_searchable'] = false;
        }

        $fieldType    = $this->attributeHelper->getFieldType($attribute);
        $fieldOptions = ['name' => $fieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig];

        $this->fields[$fieldName] = $this->fieldFactory->create($fieldOptions);

        return $this;
    }
private function initField ( AttributeInterface $ attribute ) { $ fieldName = $ attribute -> getAttributeCode ( ) ; $ fieldConfig = $ this -> attributeHelper -> getMappingFieldOptions ( $ attribute ) ; if ( $ attribute -> usesSource ( ) ) { $ optionFieldName = $ this -> attributeHelper -> getOptionTextFieldName ( $ fieldName ) ; $ fieldType = FieldInterface :: FIELD_TYPE_TEXT ; $ fieldOptions = [ 'name' => $ optionFieldName , 'type' => $ fieldType , 'fieldConfig' => $ fieldConfig ] ; $ this -> fields [ $ optionFieldName ] = $ this -> fieldFactory -> create ( $ fieldOptions ) ; // Reset parent field values : only the option text field should be used for spellcheck and autocomplete. $ fieldConfig [ 'is_used_in_spellcheck' ] = false ; $ fieldConfig [ 'is_searchable' ] = false ; } $ fieldType = $ this -> attributeHelper -> getFieldType ( $ attribute ) ; $ fieldOptions = [ 'name' => $ fieldName , 'type' => $ fieldType , 'fieldConfig' => $ fieldConfig ] ; $ this -> fields [ $ fieldName ] = $ this -> fieldFactory -> create ( $ fieldOptions ) ; return $ this ; }
Create a mapping field from an attribute.

@param AttributeInterface $attribute Entity attribute.

@return \Smile\ElasticsuiteCatalog\Model\Eav\Indexer\Fulltext\Datasource\AbstractAttributeData
Create a mapping field from an attribute .