32 $location = Service\LocationService::getInstance()->findById($locationId, $languageId);
36 $result = $location->toArray();
38 elseif($location ===
false)
40 if(ErrorService::getInstance()->
hasErrors())
42 $result = AjaxJson::createError(
68 $entity = Entity\Location::fromArray($location);
72 $parents = $entity->getParents();
76 $result = \Bitrix\Location\Entity\Location\Converter\ArrayConverter::convertParentsToArray($parents);
78 else if($parents ===
false)
80 if(ErrorService::getInstance()->
hasErrors())
82 $result = AjaxJson::createError(
100 $location = Service\LocationService::getInstance()->findByExternalId($externalId, $sourceCode, $languageId);
103 if($location && $location->getId() > 0)
105 $externalLocation = Service\LocationService::getInstance()->findByExternalId(
109 LOCATION_SEARCH_SCOPE_EXTERNAL
112 if($externalLocation)
114 $location->setAddress($externalLocation->getAddress());
121 $result = \Bitrix\Location\Entity\Location\Converter\ArrayConverter::convertToArray($location);
125 if(ErrorService::getInstance()->
hasErrors())
127 $result = AjaxJson::createError(
138 $entity = Entity\Location::fromArray($location);
139 $result = $entity->save();
142 'isSuccess' => $result->isSuccess(),
143 'errors' => $result->getErrorMessages(),
144 'location' => \Bitrix\Location\Entity\Location\Converter\ArrayConverter::convertToArray($entity)