- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/location/import/compiler/compiler.php
- Класс: BitrixSaleLocationImportCompileris
- Вызов: is::mapFiasCities
private function mapFiasCities()
{
//$this->output($this->data['MAPS']['REGIONS']);
$links = $this->getFias2YamarketRootLinks();
//$this->output($links);
$typesToSearch = array('CITY', 'VILLAGE');
// for each region and city we choose the correpongind ones from fias, saving routes
foreach($links as $id => $fiasSource)
{
$region = $this->data['MAPS']['REGIONS'][$id];
$this->output('FOR region: '.$region);
$this->output($region);
$toBeFound = array(); // among all nodes get only ones with following types
$this->getMainTreeNodesOfType(array($id), $typesToSearch, $toBeFound);
//$this->output(count($toBeFound));
if(!empty($toBeFound)) // search them in fias prepared tree
{
foreach($fiasSource as $fiasId)
{
$this->output('In: '.$fiasId);
$this->walkFiasTreeAndKeepFollowing($fiasId, $toBeFound, $typesToSearch);
}
}
$this->cleanUpFile('fias_yamarket_links', 'region_'.$region['ID']);
foreach($toBeFound as $node)
{
$exactId = '';
$exactName = '';
$exactType = '';
$exactCode = '';
if(!empty($node['MATCH']))
{
$match = array_shift($node['MATCH']);
$exactId = $match['ID'];
$exactName = $match['NAME'];
$exactType = $match['TYPE'];
$item = $this->fiasGetByAOGUID($exactId);
if($item)
{
$exactCode = $item['CODE'];
}
else
$this->output('no record in fias for: '.$exactId);
}
$data = array(
'HZ' => 'libre',
'ID' => $node['ID'],
'NAME' => $node['NAME']['RU']['NAME'],
'AOGUID' => $exactId,
'FNAME' => $exactName,
'FTYPE' => $exactType,
'CODE' => $exactCode
);
for($i = 0; $i < 3; $i++)
{
$data['VAR_AOGUID_'.$i] = '';
$data['VAR_NAME_'.$i] = '';
$data['VAR_TYPE_'.$i] = '';
}
$i = 0;
if(!empty($node['MATCH']))
{
foreach($node['MATCH'] as $item)
{
$data['VAR_AOGUID_'.$i] = $item['ID'];
$data['VAR_NAME_'.$i] = $item['NAME'];
$data['VAR_TYPE_'.$i] = $item['TYPE'];
$i++;
}
}
if(!empty($node['POSSIBLE']))
{
foreach($node['POSSIBLE'] as $item)
{
$data['VAR_AOGUID_'.$i] = $item['ID'];
$data['VAR_NAME_'.$i] = $item['NAME'];
$data['VAR_TYPE_'.$i] = $item['TYPE'];
$i++;
}
}
$this->putToFile2(
$data,
'fias_yamarket_links',
'region_'.$region['ID'],
true
);
}
//break;//tmp
}
}