• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/import/compiler/db/exporttreeukrain.php
  • Класс: BitrixSaleLocationImportCompilerDbis
  • Вызов: is::buildFromUADB
public function buildFromUADB($options)
{
	if(isset($options['NEXT_FREE_CODE']))
		$this->exportOffset = intval($options['NEXT_FREE_CODE']);

	$dbConnection = MainHttpApplication::getConnection();

	// settlements
	$res = $dbConnection->query('select ID, ZIP, ZIP_TO, TYPE_ID, CITY_ID, REGION_ID, AREA_ID, VILLAGE_ID from b_tmp_ukrain_settlement');
	while($item = $res->fetch())
	{
		$code = $this->getSettlementParentCode(array(
			'REGION_ID' => $item['REGION_ID'],
			'AREA_ID' => $item['AREA_ID']
		));

		// now there can be several situations
		$type = $this->getMappedType($item['TYPE_ID']);

		// records where CITY_ID and VILLAGE_ID filled both
		if(intval($item['CITY_ID']) && intval($item['VILLAGE_ID']))
		{
			$type = 'VILLAGE';

			// must be attached to CITY
			$code = $this->settlementParent[$item['CITY_ID']];
			$id = $item['VILLAGE_ID'];

			//$item['VILLAGE_ID']
		}
		elseif(intval($item['CITY_ID']))
		{
			$type = 'CITY';
			$id = $item['CITY_ID'];
		}

		$this->settlementParent[$key] = $this->addNode(array(
			'ID' => $item['ID'],
			'TYPE_CODE' => $type,
			'PARENT_CODE' => $code,
			'NAME' => $this->getNames($id, $type),
			'ZIP' => $item['ZIP'],
			'ZIP_TO' => $item['ZIP_TO'],
		));
	}

}