public function getFromWebserviceImport($value, $object = null, $params = [], $idMapper = null)
{
if (empty($value)) {
return null;
} else {
$value = (array) $value;
if ($value["value"] !== null && $value["unit"] !== null && $value["unitAbbreviation"] !== null) {
$unitId = $value["unit"];
if ($idMapper) {
$unitId = $idMapper->getMappedId("unit", $unitId);
}
$unit = Model\Object\QuantityValue\Unit::getById($unitId);
if ($unit && $unit->getAbbreviation() == $value["unitAbbreviation"]) {
return new \Pimcore\Model\Object\Data\QuantityValue($value["value"], $unitId);
} else {
throw new \Exception(get_class($this) . ": cannot get values from web service import - unit id and unit abbreviation do not match with local database");
}
} else {
throw new \Exception(get_class($this) . ": cannot get values from web service import - invalid data");
}
}
}