• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/migration/migrate.php
  • Класс: BitrixSaleLocationMigrationCUpdaterLocationPro
  • Вызов: CUpdaterLocationPro::copyDefaultLocations
public function copyDefaultLocations()
{
	$sRes = MainSiteTable::getList();
	$sites = array();
	while($site = $sRes->fetch())
		$sites[] = $site['LID'];

	$existed = array();
	$res = LocationDefaultSiteTable::getList();
	while($item = $res->fetch())
		$existed[$item['SITE_ID']][$item['LOCATION_CODE']] = true;

	$res = CSaleLocation::GetList(array(), array(
		'LID' => 'en',
		'LOC_DEFAULT' => 'Y'
	), false, false, array('ID'));

	while($item = $res->fetch())
	{
		foreach($sites as $site)
		{
			if(isset($existed[$site][$item['ID']]))
				continue;

			$opRes = LocationDefaultSiteTable::add(array(
				'SITE_ID' => $site,
				'LOCATION_CODE' => $item['ID']
			));
			if(!$opRes->isSuccess())
				throw new MainSystemException('Cannot add default location');
		}
	}
}