Пример #1
0
 public static function getExternalServicesList()
 {
     static $services;
     if ($services == null) {
         $res = Location\ExternalServiceTable::getList();
         $services = array();
         while ($item = $res->Fetch()) {
             $services[$item['ID']] = $item;
         }
     }
     return $services;
 }
Пример #2
0
 public function copyZipCodes()
 {
     global $DB;
     Helper::truncateTable(self::TABLE_LOCATION_EXTERNAL);
     $zipServiceId = false;
     $zip = Location\ExternalServiceTable::getList(array('filter' => array('=CODE' => 'ZIP')))->fetch();
     if (intval($zip['ID'])) {
         $zipServiceId = intval($zip['ID']);
     }
     if ($zipServiceId === false) {
         $res = Location\ExternalServiceTable::add(array('CODE' => 'ZIP'));
         if (!$res->isSuccess()) {
             throw new Main\SystemException('Cannot add external system: ' . implode(', ', $res->getErrors()), 0, __FILE__, __LINE__);
         }
         $zipServiceId = $res->getId();
     }
     if ($this->TableExists(self::TABLE_LOCATION_ZIP)) {
         $loc2External = new BlockInserter(array('entityName' => '\\Bitrix\\Sale\\Location\\ExternalTable', 'exactFields' => array('LOCATION_ID', 'XML_ID', 'SERVICE_ID'), 'parameters' => array('mtu' => 9999)));
         $res = $DB->query('select * from ' . self::TABLE_LOCATION_ZIP);
         while ($item = $res->fetch()) {
             $item['LOCATION_ID'] = trim($item['LOCATION_ID']);
             $item['ZIP'] = trim($item['ZIP']);
             if (strlen($item['LOCATION_ID']) && strlen($item['ZIP'])) {
                 $loc2External->insert(array('LOCATION_ID' => $item['LOCATION_ID'], 'XML_ID' => $item['ZIP'], 'SERVICE_ID' => $zipServiceId));
             }
         }
         $loc2External->flush();
     }
 }
Пример #3
0
 public static function getExistedServices()
 {
     $existed = array();
     $res = Location\ExternalServiceTable::getList(array('select' => array('ID', 'CODE')));
     while ($item = $res->fetch()) {
         $existed[$item['CODE']] = $item['ID'];
     }
     return $existed;
 }
Пример #4
0
 private static function getZipId()
 {
     $res = Location\ExternalServiceTable::getList(array('filter' => array('=CODE' => self::ZIP_EXT_SERVICE_CODE), 'limit' => 1))->fetch();
     if ($res) {
         return $res['ID'];
     }
     return false;
 }