Ejemplo n.º 1
0
 public static function getLocationsByZip($zip, $parameters = array())
 {
     $zip = trim($zip);
     if (!strlen($zip) || !preg_match('#^\\d+$#', $zip)) {
         throw new Main\SystemException('Empty or incorrect zip code passed');
     }
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters['filter']['=SERVICE.CODE'] = 'ZIP';
     $parameters['filter']['=XML_ID'] = $zip;
     return \Bitrix\Sale\Location\ExternalTable::getList($parameters);
 }
Ejemplo n.º 2
0
 public static function AddLocationZIP($location, $ZIP, $bSync = false)
 {
     if (self::isLocationProMigrated()) {
         try {
             if ($bSync) {
                 $res = Location\ExternalTable::getList(array('filter' => array('=SERVICE.CODE' => self::ZIP_EXT_SERVICE_CODE, '=XML_ID' => $ZIP, '=LOCATION_ID' => $location), 'select' => array('ID'), 'limit' => 1))->fetch();
                 if ($res) {
                     if (!Location\ExternalTable::update($res['ID'], array('LOCATION_ID' => $location, 'XML_ID' => $ZIP))->isSuccess()) {
                         $bSync = false;
                     }
                 }
             }
             if (!$bSync) {
                 $zipId = self::getZipId();
                 if ($zipId) {
                     Location\ExternalTable::add(array('LOCATION_ID' => $location, 'XML_ID' => $ZIP, 'SERVICE_ID' => $zipId));
                 }
             }
         } catch (Exception $e) {
             return new DB\ArrayResult(array());
         }
     } else {
         global $DB;
         $arInsert = array("LOCATION_ID" => intval($location), "ZIP" => intval($ZIP));
         if ($bSync) {
             $cnt = $DB->Update('b_sale_location_zip', $arInsert, "WHERE LOCATION_ID='" . $arInsert["LOCATION_ID"] . "' AND ZIP='" . $arInsert["ZIP"] . "'");
             if ($cnt <= 0) {
                 $bSync = false;
             }
         }
         if (!$bSync) {
             $DB->Insert('b_sale_location_zip', $arInsert);
         }
         return;
     }
 }
Ejemplo n.º 3
0
 /**
  *
  *
  *
  */
 public static function getExternalData($primary, $parameters = array())
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     if (!is_array($parameters) || empty($parameters)) {
         $parameters = array();
     }
     $parameters['filter']['LOCATION_ID'] = $primary;
     return ExternalTable::getList($parameters);
 }
Ejemplo n.º 4
0
 /**
  *
  *
  *
  */
 public static function getExternalData($primary, $parameters = array())
 {
     $primary = Assert::expectIntegerPositive($primary, false, Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_BAD_ARGUMENT_PRIMARY_UNSET_EXCEPTION'));
     if (!is_array($parameters) || empty($parameters)) {
         $parameters = array();
     }
     $parameters['filter']['LOCATION_ID'] = $primary;
     return ExternalTable::getList($parameters);
 }