• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/migration/migrate.php
  • Класс: BitrixSaleLocationMigrationCUpdaterLocationPro
  • Вызов: CUpdaterLocationPro::convertEntityLocationLinks
private function convertEntityLocationLinks($entityName)
{
	/** @var  BitrixSaleLocationConnector $class */
	$class = 				$entityName.'Table';
	$typeField = 			$class::getTypeField();
	$locationLinkField = 	$class::getLocationLinkField();
	$linkField = 			$class::getLinkField();
	$useGroups = 			$class::getUseGroups();

	$res = $class::getList();
	$links = array();

	while($item = $res->fetch())
	{
		if($useGroups)
			$links[$item[$linkField]][$item[$typeField]][] = $item[$locationLinkField];
		else
			$links[$item[$linkField]][$class::DB_LOCATION_FLAG][] = $item[$locationLinkField];
	}

	foreach($links as $entityId => $rels)
	{
		if(is_array($rels[$class::DB_LOCATION_FLAG]))
			$rels[$class::DB_LOCATION_FLAG] = $class::normalizeLocationList($rels[$class::DB_LOCATION_FLAG]);

		if(isset($rels[$class::DB_LOCATION_FLAG]) && (!is_array($rels[$class::DB_LOCATION_FLAG]) || empty($rels[$class::DB_LOCATION_FLAG])))
			unset($rels[$class::DB_LOCATION_FLAG]);

		if(isset($rels[$class::DB_GROUP_FLAG]) && (!is_array($rels[$class::DB_GROUP_FLAG]) || empty($rels[$class::DB_GROUP_FLAG])))
			unset($rels[$class::DB_GROUP_FLAG]);

		$class::resetMultipleForOwner($entityId, $rels);
	}
}