Skip to content

Commit 3afb568

Browse files
author
Oleksii Korshenko
committed
MAGETWO-52616: Bug Fixes Contribution
1 parent c951140 commit 3afb568

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,24 @@ protected function convertCustomAttributeValue($customAttributesValueArray, $dat
209209
list($customAttributeCode, $customAttributeValue) = $this->processCustomAttribute($customAttribute);
210210

211211
$type = $this->customAttributeTypeLocator->getType($customAttributeCode, $dataObjectClassName);
212-
$type = $type ? $type : TypeProcessor::ANY_TYPE;
213212

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+
);
220225
}
221226
} else {
222-
$attributeValue = $this->convertValue($customAttributeValue, $type);
227+
$attributeValue = $this->_createDataObjectForTypeAndArrayValue($type, $customAttributeValue);
223228
}
229+
224230
//Populate the attribute value data object once the value for custom attribute is derived based on type
225231
$result[$customAttributeCode] = $this->attributeValueFactory->create()
226232
->setAttributeCode($customAttributeCode)

0 commit comments

Comments
 (0)