diff --git a/src/GraphQL/DataObjectInputProcessor/InputQuantityValue.php b/src/GraphQL/DataObjectInputProcessor/InputQuantityValue.php index 976e6d68..3a86426e 100644 --- a/src/GraphQL/DataObjectInputProcessor/InputQuantityValue.php +++ b/src/GraphQL/DataObjectInputProcessor/InputQuantityValue.php @@ -36,7 +36,12 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) $attribute = $this->getAttribute(); Service::setValue($object, $attribute, function ($container, $setter) use ($newValue) { if ($newValue) { - $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation($newValue['unit']); + $unit = null; + if (isset($newValue['unitId'])) { + $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getById($newValue['unitId']); + } elseif (isset($newValue['unit'])) { + $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation($newValue['unit']); + } $inputQuantityValue = new \Pimcore\Model\DataObject\Data\InputQuantityValue($newValue['value'], $unit); return $container->$setter($inputQuantityValue); diff --git a/src/GraphQL/DataObjectInputProcessor/QuantityValue.php b/src/GraphQL/DataObjectInputProcessor/QuantityValue.php index 4a534826..e4f14889 100644 --- a/src/GraphQL/DataObjectInputProcessor/QuantityValue.php +++ b/src/GraphQL/DataObjectInputProcessor/QuantityValue.php @@ -36,7 +36,12 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) $attribute = $this->getAttribute(); Service::setValue($object, $attribute, function ($container, $setter) use ($newValue) { if ($newValue) { - $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation($newValue['unit']); + $unit = null; + if (isset($newValue['unitId'])) { + $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getById($newValue['unitId']); + } elseif (isset($newValue['unit'])) { + $unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation($newValue['unit']); + } $quantityValue = new \Pimcore\Model\DataObject\Data\QuantityValue($newValue['value'], $unit); return $container->$setter($quantityValue); diff --git a/src/GraphQL/DataObjectType/InputQuantityValueInputType.php b/src/GraphQL/DataObjectType/InputQuantityValueInputType.php index eba4a8cc..da8fe964 100644 --- a/src/GraphQL/DataObjectType/InputQuantityValueInputType.php +++ b/src/GraphQL/DataObjectType/InputQuantityValueInputType.php @@ -46,6 +46,7 @@ public function build(&$config) $config['fields'] = [ 'value' => Type::string(), 'unit' => Type::string(), + 'unitId' => Type::string() ]; } } diff --git a/src/GraphQL/DataObjectType/QuantityValueInputType.php b/src/GraphQL/DataObjectType/QuantityValueInputType.php index 0c38b5fb..f86e3d91 100644 --- a/src/GraphQL/DataObjectType/QuantityValueInputType.php +++ b/src/GraphQL/DataObjectType/QuantityValueInputType.php @@ -46,6 +46,7 @@ public function build(&$config) $config['fields'] = [ 'value' => Type::float(), 'unit' => Type::string(), + 'unitId' => Type::string() ]; } }