@@ -209,18 +209,24 @@ protected function convertCustomAttributeValue($customAttributesValueArray, $dat
209
209
list ($ customAttributeCode , $ customAttributeValue ) = $ this ->processCustomAttribute ($ customAttribute );
210
210
211
211
$ type = $ this ->customAttributeTypeLocator ->getType ($ customAttributeCode , $ dataObjectClassName );
212
- $ type = $ type ? $ type : TypeProcessor::ANY_TYPE ;
213
212
214
- if (is_array ($ customAttributeValue )) {
215
- //If type for AttributeValue's value as array is mixed, further processing is not possible
216
- if ($ type === TypeProcessor::ANY_TYPE ) {
217
- $ attributeValue = $ customAttributeValue ;
218
- } else {
219
- $ attributeValue = $ this ->_createDataObjectForTypeAndArrayValue ($ type , $ customAttributeValue );
213
+ if ($ this ->typeProcessor ->isTypeAny ($ type ) || $ this ->typeProcessor ->isTypeSimple ($ type )
214
+ || !is_array ($ customAttributeValue )
215
+ ) {
216
+ try {
217
+ $ attributeValue = $ this ->convertValue ($ customAttributeValue , $ type );
218
+ } catch (SerializationException $ e ) {
219
+ throw new SerializationException (
220
+ new Phrase (
221
+ 'Attribute "%attribute_code" has invalid value. %details ' ,
222
+ ['attribute_code ' => $ customAttributeCode , 'details ' => $ e ->getMessage ()]
223
+ )
224
+ );
220
225
}
221
226
} else {
222
- $ attributeValue = $ this ->convertValue ( $ customAttributeValue , $ type );
227
+ $ attributeValue = $ this ->_createDataObjectForTypeAndArrayValue ( $ type , $ customAttributeValue );
223
228
}
229
+
224
230
//Populate the attribute value data object once the value for custom attribute is derived based on type
225
231
$ result [$ customAttributeCode ] = $ this ->attributeValueFactory ->create ()
226
232
->setAttributeCode ($ customAttributeCode )
0 commit comments