Пример #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 createService($service)
 {
     $res = Location\ExternalServiceTable::add($service);
     if (!$res->isSuccess()) {
         throw new Main\SystemException('External service creation failed: ' . implode(', ', $res->getErrorMessages()));
     }
     return $res->getId();
 }
Пример #4
0
 /**
  * <p>Метод удаляет все местоположения из базы. Метод динамичный.</p> <br><br>
  *
  *
  * @return mixed 
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__deleteall.1cda6559.php
  * @author Bitrix
  */
 public static function DeleteAll()
 {
     global $DB;
     foreach (GetModuleEvents("sale", "OnBeforeLocationDeleteAll", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent) === false) {
             return false;
         }
     }
     if (self::isLocationProMigrated()) {
         //main
         $DB->Query("DELETE FROM " . Location\LocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\GroupTable::getTableName());
         $DB->Query("DELETE FROM " . Location\TypeTable::getTableName());
         //names
         $DB->Query("DELETE FROM " . Location\Name\LocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\Name\GroupTable::getTableName());
         $DB->Query("DELETE FROM " . Location\Name\TypeTable::getTableName());
         //links
         $DB->Query("DELETE FROM " . Location\GroupLocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\SiteLocationTable::getTableName());
         $DB->Query("DELETE FROM " . Delivery\DeliveryLocationTable::getTableName());
         //other
         $DB->Query("DELETE FROM " . Location\DefaultSiteTable::getTableName());
         $DB->Query("DELETE FROM " . Location\ExternalTable::getTableName());
         $DB->Query("DELETE FROM " . Location\ExternalServiceTable::getTableName());
     }
     $DB->Query("DELETE FROM b_sale_location2location_group");
     $DB->Query("DELETE FROM b_sale_location_group_lang");
     $DB->Query("DELETE FROM b_sale_location_group");
     $DB->Query("DELETE FROM b_sale_delivery2location");
     $DB->Query("DELETE FROM b_sale_location");
     $DB->Query("DELETE FROM b_sale_location_city_lang");
     $DB->Query("DELETE FROM b_sale_location_city");
     $DB->Query("DELETE FROM b_sale_location_country_lang");
     $DB->Query("DELETE FROM b_sale_location_country");
     $DB->Query("DELETE FROM b_sale_location_region_lang");
     $DB->Query("DELETE FROM b_sale_location_region");
     $DB->Query("DELETE FROM b_sale_location_zip");
     foreach (GetModuleEvents("sale", "OnLocationDeleteAll", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent);
     }
 }