protected function normalizeAttributeValue($storeId, $attributeCode, $value)
    {
        $values = $this->ensureArray($value);
        $values = array_map(function($value) { return $this->scalarValue($value); }, $values);

        $attribute = $this->eavConfig->getAttribute(Product::ENTITY, $attributeCode);
        // Attribute does not exists so just return value
        if (!$attribute->getId()) {
            return $values;
        }

        // Apparently Magento adds a default source model to the attribute even if it does not use a source
        if (!$attribute->usesSource()) {
            return $values;
        }

        // Explode values if source is used (multi select)
        $values = $this->explodeValues($values);
        if (!$attribute->getSource() instanceof SourceInterface) {
            return $values;
        }

        $result = [];
        foreach ($values as $attributeValue) {
            $map = $this->getAttributeOptionMap($storeId, $attribute);
            $result[] = $map[$attributeValue] ?? null;
        }

        return $result;
    }
protected function normalizeAttributeValue($storeId, $attributeCode, $value)
    {
        $values = $this->ensureArray($value);
        $values = array_map(function($value) { return $this->scalarValue($value); }, $values);

        $attribute = $this->eavConfig->getAttribute(Product::ENTITY, $attributeCode);
        // Attribute does not exists so just return value
        if (!$attribute->getId()) {
            return $values;
        }

        // Apparently Magento adds a default source model to the attribute even if it does not use a source
        if (!$attribute->usesSource()) {
            return $values;
        }

        // Explode values if source is used (multi select)
        $values = $this->explodeValues($values);
        if (!$attribute->getSource() instanceof SourceInterface) {
            return $values;
        }

        $result = [];
        foreach ($values as $attributeValue) {
            $map = $this->getAttributeOptionMap($storeId, $attribute);
            $result[] = $map[$attributeValue] ?? null;
        }

        return $result;
    }
protected function normalizeAttributeValue ( $ storeId , $ attributeCode , $ value ) { $ values = $ this -> ensureArray ( $ value ) ; $ values = array_map ( function ( $ value ) { return $ this -> scalarValue ( $ value ) ; } , $ values ) ; $ attribute = $ this -> eavConfig -> getAttribute ( Product :: ENTITY , $ attributeCode ) ; // Attribute does not exists so just return value if ( ! $ attribute -> getId ( ) ) { return $ values ; } // Apparently Magento adds a default source model to the attribute even if it does not use a source if ( ! $ attribute -> usesSource ( ) ) { return $ values ; } // Explode values if source is used (multi select) $ values = $ this -> explodeValues ( $ values ) ; if ( ! $ attribute -> getSource ( ) instanceof SourceInterface ) { return $ values ; } $ result = [ ] ; foreach ( $ values as $ attributeValue ) { $ map = $ this -> getAttributeOptionMap ( $ storeId , $ attribute ) ; $ result [ ] = $ map [ $ attributeValue ] ?? null ; } return $ result ; }
Convert attribute value to array of scalar values.

@param int $storeId
@param string $attributeCode
@param mixed $value
@return array
Convert attribute value to array of scalar values .