Ejemplo n.º 1
0
 /**
  * If zip codes imported to locations, we try to link regions to zones
  * using file /bitrix/modules/sale/delivery/rus_post/zip_zones.csv created
  * from http://info.russianpost.ru/database/tzones.html
  */
 public function importZonesFromZipCsv()
 {
     $COL_ZIP = 0;
     $COL_ZONE = 1;
     $csvFile = CSaleHelper::getCsvObject(DELIVERY_RP_CSV_PATH . '/zip_zones.csv');
     $arRes = $csvFile->Fetch();
     $arRegions = CSaleDeliveryHelper::getRegionsList();
     $arRegionsZones = array();
     while ($arRes = $csvFile->Fetch()) {
         $location = CSaleLocation::GetByZIP($arRes[$COL_ZIP]);
         if ($location === false) {
             continue;
         }
         if (isset($arRegions[$location['REGION_ID']])) {
             $arRegionsZones[$location['REGION_ID']] = $arRes[$COL_ZONE];
         }
         unset($arRegions[$location['REGION_ID']]);
         if (empty($arRegions)) {
             break;
         }
     }
     return $arRegionsZones;
 }