Skip to content

Commit a0d9f47

Browse files
AnujNehraAnujNehra
authored andcommitted
ACP2E-1986: Rest api V1/carts/mine/estimate-shipping-methods show 500 Error
1 parent 86d111d commit a0d9f47

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -293,43 +293,42 @@ protected function _createFromArray($className, $data)
293293
// Converts snake_case to uppercase CamelCase to help form getter/setter method names
294294
// This use case is for REST only. SOAP request data is already camel cased
295295
$camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($propertyName);
296-
$methodName = 'get'.$camelCaseProperty;
297296
try {
298297
$methodName = $this->getNameFinder()->getGetterMethodName($class, $camelCaseProperty);
299-
} catch (\LogicException $e) {
300-
$this->processInputErrorForNestedSet([$camelCaseProperty]);
301-
}
302-
if (!isset($this->methodReflectionStorage[$className . $methodName])) {
303-
$this->methodReflectionStorage[$className . $methodName] = $class->getMethod($methodName);
304-
}
305-
$methodReflection = $this->methodReflectionStorage[$className . $methodName];
306-
if ($methodReflection->isPublic()) {
307-
$returnType = $this->typeProcessor->getGetterReturnType($methodReflection)['type'];
308-
try {
309-
$setterName = $this->getNameFinder()->getSetterMethodName($class, $camelCaseProperty);
310-
} catch (\Exception $e) {
311-
if (empty($value)) {
312-
continue;
313-
} else {
314-
throw $e;
315-
}
298+
if (!isset($this->methodReflectionStorage[$className . $methodName])) {
299+
$this->methodReflectionStorage[$className . $methodName] = $class->getMethod($methodName);
316300
}
317-
try {
318-
if ($camelCaseProperty === 'CustomAttributes') {
319-
$setterValue = $this->convertCustomAttributeValue($value, $className);
320-
} else {
321-
$setterValue = $this->convertValue($value, $returnType);
301+
$methodReflection = $this->methodReflectionStorage[$className . $methodName];
302+
if ($methodReflection->isPublic()) {
303+
$returnType = $this->typeProcessor->getGetterReturnType($methodReflection)['type'];
304+
try {
305+
$setterName = $this->getNameFinder()->getSetterMethodName($class, $camelCaseProperty);
306+
} catch (\Exception $e) {
307+
if (empty($value)) {
308+
continue;
309+
} else {
310+
throw $e;
311+
}
322312
}
323-
} catch (SerializationException $e) {
324-
throw new SerializationException(
325-
new Phrase(
326-
'Error occurred during "%field_name" processing. %details',
327-
['field_name' => $propertyName, 'details' => $e->getMessage()]
328-
)
329-
);
313+
try {
314+
if ($camelCaseProperty === 'CustomAttributes') {
315+
$setterValue = $this->convertCustomAttributeValue($value, $className);
316+
} else {
317+
$setterValue = $this->convertValue($value, $returnType);
318+
}
319+
} catch (SerializationException $e) {
320+
throw new SerializationException(
321+
new Phrase(
322+
'Error occurred during "%field_name" processing. %details',
323+
['field_name' => $propertyName, 'details' => $e->getMessage()]
324+
)
325+
);
326+
}
327+
$this->serviceInputValidator->validateEntityValue($object, $propertyName, $setterValue);
328+
$object->{$setterName}($setterValue);
330329
}
331-
$this->serviceInputValidator->validateEntityValue($object, $propertyName, $setterValue);
332-
$object->{$setterName}($setterValue);
330+
} catch (\LogicException $e) {
331+
$this->processInputErrorForNestedSet([$camelCaseProperty]);
333332
}
334333
}
335334

0 commit comments

Comments
 (0)