public static function copyDefaultLocations() { $sRes = Main\SiteTable::getList(); $sites = array(); while ($site = $sRes->fetch()) { $sites[] = $site['LID']; } $existed = array(); $res = Location\DefaultSiteTable::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 = Location\DefaultSiteTable::add(array('SITE_ID' => $site, 'LOCATION_CODE' => $item['ID'])); if (!$opRes->isSuccess()) { throw new Main\SystemException('Cannot add default location'); } } } }