Smile\ElasticsuiteCatalog\Helper\Attribute::prepareIndexValue PHP Method

prepareIndexValue() public method

For attribute using options the option value is also added to the result which contains two keys : - one is "attribute_code" and contained the option id(s) - the other one is "option_text_attribute_code" and contained option value(s) All value are transformed into arays to have a more simple management of multivalued attributes merging on composite products). ES doesn't care of having array of int when it an int is required.
public prepareIndexValue ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, mixed $value ) : array
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
$storeId integer Store id.
$value mixed Raw value to be parsed.
return array
    public function prepareIndexValue(AttributeInterface $attribute, $storeId, $value)
    {
        $attributeCode = $attribute->getAttributeCode();
        $values = [];
        $mapperKey = 'simple_' . $attribute->getId();
        if (!isset($this->attributeMappers[$mapperKey])) {
            $this->attributeMappers[$mapperKey] = function ($value) use($attribute) {
                return $this->prepareSimpleIndexAttributeValue($attribute, $value);
            };
        }
        if ($attribute->usesSource() && !is_array($value)) {
            $value = explode(',', $value);
        }
        if (!is_array($value)) {
            $value = [$value];
        }
        $value = array_map($this->attributeMappers[$mapperKey], $value);
        $value = array_filter($value);
        $value = array_values($value);
        $values[$attributeCode] = $value;
        if ($attribute->usesSource()) {
            $optionTextFieldName = $this->getOptionTextFieldName($attributeCode);
            $optionTextValues = $this->getIndexOptionsText($attribute, $storeId, $value);
            $optionTextValues = array_filter($optionTextValues);
            $optionTextValues = array_values($optionTextValues);
            $values[$optionTextFieldName] = $optionTextValues;
        }
        return array_filter($values);
    }