Пример #1
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);
 }
Пример #2
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);
 }
Пример #3
0
 public static function getIndexMap()
 {
     $locationTable = Location\LocationTable::getTableName();
     $locationNameTable = Location\Name\LocationTable::getTableName();
     $locationExternalTable = Location\ExternalTable::getTableName();
     return array('IX_B_SALE_LOC_MARGINS' => array('TABLE' => $locationTable, 'COLUMNS' => array('LEFT_MARGIN', 'RIGHT_MARGIN')), 'IX_B_SALE_LOC_MARGINS_REV' => array('TABLE' => $locationTable, 'COLUMNS' => array('RIGHT_MARGIN', 'LEFT_MARGIN')), 'IX_B_SALE_LOC_PARENT' => array('TABLE' => $locationTable, 'COLUMNS' => array('PARENT_ID')), 'IX_B_SALE_LOC_DL' => array('TABLE' => $locationTable, 'COLUMNS' => array('DEPTH_LEVEL')), 'IX_B_SALE_LOC_TYPE' => array('TABLE' => $locationTable, 'COLUMNS' => array('TYPE_ID')), 'IX_B_SALE_LOC_NAME_NAME_U' => array('TABLE' => $locationNameTable, 'COLUMNS' => array('NAME_UPPER')), 'IX_B_SALE_LOC_NAME_LI_LI' => array('TABLE' => $locationNameTable, 'COLUMNS' => array('LOCATION_ID', 'LANGUAGE_ID')), 'IX_B_SALE_LOC_EXT_LID_SID' => array('TABLE' => $locationExternalTable, 'COLUMNS' => array('LOCATION_ID', 'SERVICE_ID')), 'IXS_LOCATION_COUNTRY_ID' => array('TABLE' => $locationTable, 'COLUMNS' => array('COUNTRY_ID')), 'IXS_LOCATION_REGION_ID' => array('TABLE' => $locationTable, 'COLUMNS' => array('REGION_ID')), 'IXS_LOCATION_CITY_ID' => array('TABLE' => $locationTable, 'COLUMNS' => array('CITY_ID')), 'IX_B_SALE_LOCATION_1' => array('TABLE' => $locationTable, 'COLUMNS' => array('COUNTRY_ID'), 'DROP_ONLY' => true), 'IX_B_SALE_LOCATION_2' => array('TABLE' => $locationTable, 'COLUMNS' => array('REGION_ID'), 'DROP_ONLY' => true), 'IX_B_SALE_LOCATION_3' => array('TABLE' => $locationTable, 'COLUMNS' => array('CITY_ID'), 'DROP_ONLY' => true));
 }
Пример #4
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;
     }
 }
Пример #5
0
 protected function stageDeleteAll()
 {
     switch ($this->step) {
         case 0:
             $this->dbConnection->query('truncate table ' . Location\LocationTable::getTableName());
             break;
         case 1:
             $this->dbConnection->query('truncate table ' . Location\Name\LocationTable::getTableName());
             break;
         case 2:
             $this->dbConnection->query('truncate table ' . Location\ExternalTable::getTableName());
             break;
         case 3:
             Location\GroupLocationTable::deleteAll();
             break;
         case 4:
             Location\SiteLocationTable::deleteAll();
             break;
     }
     $this->nextStep();
     if ($this->step >= 4) {
         $this->nextStage();
     }
 }
Пример #6
0
	public function restoreIndexes($certainIndex = false)
	{
		$locationTable = Location\LocationTable::getTableName();
		$locationNameTable = Location\Name\LocationTable::getTableName();
		$locationExternalTable = Location\ExternalTable::getTableName();

		$map = array(
			'IX_B_SALE_LOC_MARGINS' => array('TABLE' => $locationTable, 'COLUMNS' => array('LEFT_MARGIN', 'RIGHT_MARGIN')),
			'IX_B_SALE_LOC_MARGINS_REV' => array('TABLE' => $locationTable, 'COLUMNS' => array('RIGHT_MARGIN', 'LEFT_MARGIN')),
			'IX_B_SALE_LOC_PARENT' => array('TABLE' => $locationTable, 'COLUMNS' => array('PARENT_ID')),
			'IX_B_SALE_LOC_DL' => array('TABLE' => $locationTable, 'COLUMNS' => array('DEPTH_LEVEL')),
			'IX_B_SALE_LOC_TYPE' => array('TABLE' => $locationTable, 'COLUMNS' => array('TYPE_ID')),
			'IX_B_SALE_LOC_NAME_NAME_U' => array('TABLE' => $locationNameTable, 'COLUMNS' => array('NAME_UPPER')),
			'IX_B_SALE_LOC_NAME_LI_LI' => array('TABLE' => $locationNameTable, 'COLUMNS' => array('LOCATION_ID', 'LANGUAGE_ID')),
			'IX_B_SALE_LOC_EXT_LID_SID' => array('TABLE' => $locationExternalTable, 'COLUMNS' => array('LOCATION_ID', 'SERVICE_ID')),
		);

		foreach($map as $ixName => $ixData)
		{
			if($certainIndex !== false && $certainIndex != $ixName)
				continue;

			if($this->checkIndexExistsByName($ixName, $ixData['TABLE']))
				return false;

			$this->dbConnection->query('CREATE INDEX '.$ixName.' ON '.$ixData['TABLE'].' ('.implode(', ', $ixData['COLUMNS']).')');
		}
	}
Пример #7
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);
 }