25 $type = $location->getType() === Location\Type::UNKNOWN ? Address\FieldType::ADDRESS_LINE_2 : $location->getType();
27 $result = (
new Address($location->getLanguageId()))
28 ->setLatitude($location->getLatitude())
29 ->setLongitude($location->getLongitude())
30 ->setFieldValue($type, $location->getName());
32 if($parents = $location->getParents())
35 foreach ($parents as $parent)
37 $result->
setFieldValue($parent->getType(), $parent->getName());
41 if($fields = $location->getAllFieldsValues())
43 foreach($fields as $type => $value)
45 if(!$result->isFieldExist($type))
47 $result->setFieldValue($type, $value);