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);
}