本文整理汇总了PHP中Bitrix\Sale\Location\LocationTable类的典型用法代码示例。如果您正苦于以下问题:PHP LocationTable类的具体用法?PHP LocationTable怎么用?PHP LocationTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocationTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRegionsList
/**
* getRegionsList
* @return array regions (locations) list
*/
public static function getRegionsList($countryId = 0, $bFlip = false)
{
static $arRegions = array();
$flipIndex = intval($bFlip);
if (isset($arRegions[$countryId][$flipIndex])) {
return $arRegions[$countryId][$flipIndex];
}
if (CSaleLocation::isLocationProMigrated()) {
$types = array();
$res = \Bitrix\Sale\Location\TypeTable::getList(array('select' => array('ID', 'CODE')));
while ($item = $res->fetch()) {
$types[$item['CODE']] = $item['ID'];
}
$filter = array(array('LOGIC' => 'OR', array('=TYPE_ID' => $types['CITY'], '=NAME.LANGUAGE_ID' => LANGUAGE_ID, array('LOGIC' => 'OR', array('=PARENT.TYPE_ID' => $types['COUNTRY']), array('=PARENT.TYPE_ID' => $types['COUNTRY_DISTRICT']), array('=PARENT_ID' => '0'))), array('=TYPE_ID' => $types['REGION'])));
if (intval($countryId)) {
$filter['=PARENTS.TYPE_ID'] = $types['COUNTRY'];
$filter['=PARENTS.ID'] = $countryId;
}
$dbRegionList = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => $filter, 'select' => array('ID', 'CODE', 'NAME_LANG' => 'NAME.NAME'), 'order' => array('NAME.NAME' => 'asc')));
} else {
$arFilterRegion = array();
if (intval($countryId) > 0) {
$arFilterRegion["COUNTRY_ID"] = $countryId;
}
$dbRegionList = CSaleLocation::GetRegionList(array("NAME_LANG" => "ASC"), $arFilterRegion, LANGUAGE_ID);
}
$key = 'ID';
while ($arRegionList = $dbRegionList->Fetch()) {
if ($key == 'ID' && isset($arRegionList['CODE'])) {
$key = 'CODE';
}
if ($key == 'CODE' && strlen($arRegionList['CODE']) <= 0) {
continue;
}
$arRegions[$countryId][0][$arRegionList[$key]] = $arRegionList["NAME_LANG"];
// $bFlip == false
$arRegions[$countryId][1][$arRegionList["NAME_LANG"]] = $arRegionList[$key];
// $bFlip == true
}
return isset($arRegions[$countryId][$flipIndex]) ? $arRegions[$countryId][$flipIndex] : array();
}
示例2: initializeData
public static function initializeData()
{
$locationTable = Location\LocationTable::getTableName();
$groupLocationTable = Location\GroupLocationTable::getTableName();
$siteLocationTable = Location\SiteLocationTable::getTableName();
// ORACLE: OK, MSSQL: OK
$sql = "\n\t\t\tinsert into " . static::getTableName() . " \n\t\t\t\t(LOCATION_ID, SITE_ID) \n\t\t\tselect LC.ID, LS.SITE_ID\n\t\t\t\tfrom " . $siteLocationTable . " LS\n\t\t\t\t\tinner join " . $locationTable . " L on LS.LOCATION_ID = L.ID and LS.LOCATION_TYPE = 'L'\n\t\t\t\t\tinner join " . $locationTable . " LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN\n\t\t\tunion \n\t\t\tselect LC.ID, LS.SITE_ID\n\t\t\t\tfrom " . $siteLocationTable . " LS\n\t\t\t\t\tinner join " . $groupLocationTable . " LG on LS.LOCATION_ID = LG.LOCATION_GROUP_ID and LS.LOCATION_TYPE = 'G'\n\t\t\t\t\tinner join " . $locationTable . " L on LG.LOCATION_ID = L.ID\n\t\t\t\t\tinner join " . $locationTable . " LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN\n\t\t";
Main\HttpApplication::getConnection()->query($sql);
}
示例3: getUpperCityId
protected static function getUpperCityId($locationId)
{
if (strlen($locationId) <= 0) {
return 0;
}
$res = LocationTable::getList(array('filter' => array(array('LOGIC' => 'OR', '=CODE' => $locationId, '=ID' => $locationId), '=PARENTS.TYPE.CODE' => 'CITY'), 'select' => array('ID', 'CODE', 'PID' => 'PARENTS.ID')));
if ($loc = $res->fetch()) {
return $loc['PID'];
}
return 0;
}
示例4: isLocationsCreated
public static function isLocationsCreated()
{
if (CSaleLocation::isLocationProMigrated()) {
$res = Location\LocationTable::getList(array('select' => array('CNT')))->fetch();
return $res['CNT'] > 0;
}
$dbResultList = CSaleLocation::GetList();
if ($dbResultList->Fetch()) {
return true;
}
return false;
}
示例5: reInitData
public static function reInitData()
{
static::cleanUp();
$offset = 0;
$stat = array();
$types = array();
$typeSort = array();
$res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
while ($item = $res->fetch()) {
if ($item['CODE'] == 'CITY' || $item['CODE'] == 'VILLAGE' || $item['CODE'] == 'STREET') {
$types[$item['CODE']] = $item['ID'];
}
$typeSort[$item['ID']] = $item['SORT'];
}
$typesBack = array_flip($types);
//_print_r($types);
//_print_r($typeSort);
while (true) {
$res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID'), 'filter' => array('=TYPE_ID' => array_values($types)), 'limit' => self::STEP_SIZE, 'offset' => $offset));
$cnt = 0;
while ($item = $res->fetch()) {
$resPath = Location\LocationTable::getPathToNode($item['ID'], array('select' => array('ID', 'TYPE_ID'), 'filter' => array('=TYPE_ID' => array_values($types))));
$path = array();
while ($pItem = $resPath->fetch()) {
$path[$typesBack[$pItem['TYPE_ID']]] = $pItem['ID'];
}
//_print_r($path);
$data = array('CITY_ID' => isset($path['CITY']) ? $path['CITY'] : 0, 'VILLAGE_ID' => isset($path['VILLAGE']) ? $path['VILLAGE'] : 0, 'STREET_ID' => isset($path['STREET']) ? $path['STREET'] : 0, 'TYPE_SORT' => $typeSort[$item['TYPE_ID']], 'LOCATION_ID' => $item['ID']);
//_print_r($data);
foreach ($data as &$value) {
$value = "'" . $value . "'";
}
//static::add($data);
$GLOBALS['DB']->query("insert into " . static::getTableName() . " (CITY_ID, VILLAGE_ID, STREET_ID, TYPE_SORT, LOCATION_ID) values (" . implode(', ', $data) . ")");
$cnt++;
}
if (!$cnt) {
break;
}
$offset += self::STEP_SIZE;
}
}
示例6: processSearchRequestV2GetAdditional
protected static function processSearchRequestV2GetAdditional(&$data, $parameters)
{
if (!empty($data['ITEMS']) && is_array($parameters['additionals'])) {
if (in_array('PATH', $parameters['additionals'])) {
// show path to each found node
static::processSearchRequestV2GetAdditionalPathNodes($data, $parameters);
}
// show common count of items by current filter
if (in_array('CNT_BY_FILTER', $parameters['additionals']) && is_array($parameters['filter'])) {
$item = Location\LocationTable::getList(array('select' => array('CNT'), 'filter' => $parameters['filter']))->fetch();
$data['ETC']['CNT_BY_FILTER'] = $item['CNT'];
}
// show parent item in case of PARENT_ID condition in filter
if (in_array('PARENT_ITEM', $parameters['additionals'])) {
$id = false;
if (intval($parameters['filter']['=PARENT_ID'])) {
$id = intval($parameters['filter']['=PARENT_ID']);
} elseif (intval($parameters['filter']['PARENT_ID'])) {
$id = intval($parameters['filter']['PARENT_ID']);
}
if ($id !== false) {
$path = array();
$data['ETC']['PATH_ITEMS'] = array();
$res = Location\LocationTable::getPathToNode($id, array('select' => array('VALUE' => 'ID', 'CODE', 'TYPE_ID', 'DISPLAY' => 'NAME.NAME'), 'filter' => array('=NAME.LANGUAGE_ID' => strlen($parameters['filter']['=NAME.LANGUAGE_ID']) ? $parameters['filter']['=NAME.LANGUAGE_ID'] : LANGUAGE_ID)));
$node = array();
while ($item = $res->fetch()) {
$path[] = intval($item['VALUE']);
$data['ETC']['PATH_ITEMS'][$item['VALUE']] = $item;
$node = $item;
}
$node['PATH'] = array_reverse($path);
$data['ETC']['PARENT_ITEM'] = $node;
}
}
}
return $data;
}
示例7: calculatePackPrice
private static function calculatePackPrice($arPackage, $profile, $arConfig, $arLocationTo)
{
$arDebug = array();
/*1 Land price
1.1 Base Price less 10 kg*/
$code = self::getRegionCodeByOldName($arLocationTo['REGION_NAME_LANG']);
// old location
if (strlen($code) <= 0 && CSaleLocation::isLocationProMigrated()) {
$dbRes = Location\LocationTable::getList(array('filter' => array('=TYPE.CODE' => 'REGION', '=REGION_ID' => intval($arLocationTo["REGION_ID"]), '=CITY_ID' => false), 'select' => array('ID', 'CODE', 'NAME')));
if ($locReg = $dbRes->fetch()) {
$code = $locReg["CODE"];
}
}
if (strlen($code) <= 0) {
throw new \Bitrix\Main\SystemException(GetMessage("SALE_DH_RP_ERROR_LOCATION_NOT_FOUND"));
}
$zoneTo = self::getConfValue($arConfig, 'REG_' . $code);
$basePrice = floatval(self::getConfValue($arConfig, 'ZONE_RATE_MAIN_' . $zoneTo));
$arDebug[] = 'Base Price less 500 g: ' . $basePrice;
if ($arPackage['WEIGHT'] > self::$BASE_WEIGHT) {
$addWeight = ceil($arPackage['WEIGHT'] / self::$BASE_WEIGHT - 1);
$addPrice = floatval(self::getConfValue($arConfig, 'ZONE_RATE_ADD_' . $zoneTo));
$arDebug[] = 'Price for additional weight more than 500 g: ' . $addWeight * $addPrice;
$basePrice += $addWeight * $addPrice;
}
$totalPrice = $basePrice;
/* 1.2 Service "heavy weight" 10 - 20 kg*/
$hwPrice = 0;
if ($arPackage['WEIGHT'] >= self::$MAX_WEIGHT) {
$hwTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_HEAVY_WEIGHT . '_value'));
$hwPrice += $totalPrice * $hwTarif / 100;
$arDebug[] = 'Heavy weight: ' . $hwPrice;
$totalPrice += $hwPrice;
}
/* 1.5 Service "fragile" */
$fPrice = 0;
if (self::isConfCheckedVal($arConfig, 'service_' . self::$TARIF_FRAGILE . '_enabled')) {
$fTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_FRAGILE . '_value'));
$fPrice += $totalPrice * $fTarif / 100;
$arDebug[] = 'Fragile: ' . $fPrice;
$totalPrice += $fPrice;
}
/* 4. Service "declared value" */
$dvPrice = 0;
if (self::isConfCheckedVal($arConfig, 'service_' . self::$TARIF_DECLARED_VAL . '_enabled')) {
$dvTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_DECLARED_VAL . '_value'));
$dvPrice += ($arPackage['PRICE'] + $totalPrice) * $dvTarif;
$arDebug[] = 'Declared value: ' . $dvPrice;
$totalPrice += $dvPrice;
}
if ($profile == 'avia') {
$aviaPrice = 0;
$aviaPrice = floatval(self::getConfValue($arConfig, 'tarif_avia_' . self::$TARIF_AVIA_STANDART . '_value'));
$arDebug[] = 'avia price: ' . $aviaPrice;
$totalPrice += $aviaPrice;
$aviaHeavyPrice = 0;
if ($arPackage['WEIGHT'] > self::$MAX_WEIGHT) {
$aviaHeavyPrice = floatval(self::getConfValue($arConfig, 'tarif_avia_' . self::$TARIF_AVIA_HEAVY . '_value'));
$arDebug[] = 'avia heavy price: ' . $aviaHeavyPrice;
$totalPrice += $aviaHeavyPrice;
}
}
return $totalPrice;
}
示例8: DeleteAll
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);
}
示例9: reInitData
public static function reInitData($parameters = array())
{
static::createTables();
$offset = 0;
$stat = array();
$types = array();
$typeSort = array();
$res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
$allowedTypes = array('REGION', 'SUBREGION', 'CITY', 'VILLAGE', 'STREET');
while ($item = $res->fetch()) {
if (in_array($item['CODE'], $allowedTypes)) {
$types[$item['CODE']] = $item['ID'];
}
$typeSort[$item['ID']] = $item['SORT'];
}
$typesBack = array_flip($types);
//print_r($types);
//_print_r($typeSort);
$wordChain = array();
$pathChain = array();
//_dump_r('GO!');
$prevDepth = 0;
while (true) {
$res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'LNAME' => 'NAME.NAME', 'DEPTH_LEVEL', 'SORT'), 'filter' => array('=TYPE_ID' => array_values($types), '=NAME.LANGUAGE_ID' => LANGUAGE_ID), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $offset));
$cnt = 0;
while ($item = $res->fetch()) {
if ($item['DEPTH_LEVEL'] < $prevDepth) {
//print('DROP to '.$item['DEPTH_LEVEL'].'<br />');
// drop chain to DEPTH_LEVEL inclusively
$newWC = array();
$newPC = array();
foreach ($wordChain as $dl => $name) {
if ($dl >= $item['DEPTH_LEVEL']) {
break;
}
$newWC[$dl] = $name;
}
$wordChain = $newWC;
foreach ($pathChain as $dl => $id) {
if ($dl >= $item['DEPTH_LEVEL']) {
break;
}
$newPC[$dl] = $id;
}
$pathChain = $newPC;
}
$wordChain[$item['DEPTH_LEVEL']] = $item['LNAME'];
$pathChain[$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']);
$prevDepth = $item['DEPTH_LEVEL'];
//print($item['DEPTH_LEVEL'].' - '.implode(' ', WordStatTable::parseQuery(implode(' ', $wordChain))).'<br />');
$parsed = WordStatTable::parseQuery(implode(' ', $wordChain));
$wordMap = array();
$i = 1;
foreach ($parsed as $word) {
$wordMap['W_' . $i] = $word;
$i++;
}
$pathMap = array();
foreach ($pathChain as $elem) {
$pathMap[$typesBack[$elem['TYPE']] . '_ID'] = $elem['ID'];
}
$data = array_merge($wordMap, $pathMap, array('LOCATION_ID' => $item['ID'], 'TYPE_ID' => $item['TYPE_ID'], 'TYPE_SORT' => $typeSort[$item['TYPE_ID']], 'SORT' => $item['SORT'], 'WORD_COUNT' => count($wordMap)));
//print('<pre>');
//print('</pre>');
try {
static::add($data);
} catch (\Exception $e) {
_dump_r('Cant add ' . implode(' ', $wordChain) . ' (' . count($wordMap) . ')<br />');
// duplicate or smth
}
$cnt++;
}
if (!$cnt) {
break;
}
$offset += self::STEP_SIZE;
}
}
示例10: stageConvertTree
protected function stageConvertTree()
{
if($this->getStep() == 0)
{
$this->migrator->convertTree();
$this->nextStep();
}
else
{
Location\LocationTable::resetLegacyPath();
$this->nextStage();
}
}
示例11: getLocationStringByCondition
protected static function getLocationStringByCondition($condition, $behaviour = array('INVERSE' => false, 'DELIMITER' => ', ', 'LANGUAGE_ID' => LANGUAGE_ID))
{
if (isset($behaviour) && !is_array($behaviour)) {
$behaviour = array();
}
if (!isset($behaviour['DELIMITER'])) {
$behaviour['DELIMITER'] = ', ';
}
if (!isset($behaviour['LANGUAGE_ID'])) {
$behaviour['LANGUAGE_ID'] = LANGUAGE_ID;
}
try {
$res = Location\LocationTable::getPathToNodeByCondition($condition, array('select' => array('LNAME' => 'NAME.NAME'), 'filter' => array('=NAME.LANGUAGE_ID' => $behaviour['LANGUAGE_ID'])));
$path = array();
while ($item = $res->fetch()) {
$path[] = $item['LNAME'];
}
if ($behaviour['INVERSE']) {
$path = array_reverse($path);
}
return implode($behaviour['DELIMITER'], $path);
} catch (\Bitrix\Main\SystemException $e) {
return '';
}
}
示例12: insertTreeInfo
private function insertTreeInfo()
{
// We make temporal table, place margins, parent and lang data into it, then perform an update of the old table from the temporal one.
$this->createTemporalTable(self::TABLE_TEMP_TREE, array('ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'PARENT_ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'TYPE_ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'DEPTH_LEVEL' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'LEFT_MARGIN' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'RIGHT_MARGIN' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)'))));
$handle = new BlockInserter(array('tableName' => self::TABLE_TEMP_TREE, 'exactFields' => array('ID' => array('data_type' => 'integer'), 'PARENT_ID' => array('data_type' => 'integer'), 'TYPE_ID' => array('data_type' => 'integer'), 'DEPTH_LEVEL' => array('data_type' => 'integer'), 'LEFT_MARGIN' => array('data_type' => 'integer'), 'RIGHT_MARGIN' => array('data_type' => 'integer')), 'parameters' => array('mtu' => 9999)));
// fill temporal table
if (is_array($this->data['TREE'])) {
foreach ($this->data['TREE'] as $id => $node) {
$handle->insert(array('ID' => $id, 'PARENT_ID' => $node['PARENT_ID'], 'TYPE_ID' => $node['TYPE_ID'], 'DEPTH_LEVEL' => $node['DEPTH_LEVEL'], 'LEFT_MARGIN' => $node['LEFT_MARGIN'], 'RIGHT_MARGIN' => $node['RIGHT_MARGIN']));
}
}
$handle->flush();
// merge temp table with location table
Location\LocationTable::mergeRelationsFromTemporalTable(self::TABLE_TEMP_TREE, array('TYPE_ID', 'PARENT_ID'));
$this->dropTable(self::TABLE_TEMP_TREE);
}
示例13: processSearchGetAdditional
protected static function processSearchGetAdditional($result)
{
$result = parent::processSearchGetAdditional($result);
// get common path of parent
if(isset($_REQUEST['FILTER']['PARENT_ID']))
{
$path = array();
$result['ETC']['PATH_NAMES'] = array();
if($pId = intval($_REQUEST['FILTER']['PARENT_ID']))
{
$res = Location\LocationTable::getPathToNode($pId, array(
'select' => array(
'ID',
'CODE',
'TYPE_ID',
'LNAME' => 'NAME.NAME'
),
'filter' => array(
'NAME.LANGUAGE_ID' => static::processSearchRequestGetLang()
)
));
$res->addReplacedAliases(array('LNAME' => 'NAME'));
$node = array();
while($item = $res->fetch())
{
$path[] = intval($item['ID']);
$result['ETC']['PATH_NAMES'][$item['ID']] = $item['NAME'];
$node = $item;
}
$node['PATH'] = array_reverse($path);
$result['ETC']['PARENT_ITEM'] = $node;
}
}
return $result;
}
示例14: RebindLocationTriplet
protected static function RebindLocationTriplet($fields = array())
{
$country = intval($fields['COUNTRY_ID']);
$region = intval($fields['REGION_ID']);
$city = intval($fields['CITY_ID']);
foreach (GetModuleEvents('sale', 'OnBeforeLocationAdd', true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($fields)) === false) {
return false;
}
}
if ($region && $country) {
$uRes = \Bitrix\Sale\Location\LocationTable::update($region, array('PARENT_ID' => $country));
}
if ($city) {
if ($region) {
$uRes = \Bitrix\Sale\Location\LocationTable::update($city, array('PARENT_ID' => $region));
} elseif ($country) {
$uRes = \Bitrix\Sale\Location\LocationTable::update($city, array('PARENT_ID' => $country));
}
}
if (intval($fields['SORT'])) {
$loc2Update = $city ? $city : ($region ? $region : ($country ? $country : false));
if ($loc2Update) {
$uRes = \Bitrix\Sale\Location\LocationTable::update($loc2Update, array('SORT' => $fields['SORT']));
}
}
foreach (GetModuleEvents('sale', 'OnLocationAdd', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($loc2Update, $fields));
}
return $loc2Update;
}
示例15: convertOldToNew
static function convertOldToNew(array $property)
{
if (isset($property['REQUIED']) && !empty($property['REQUIED'])) {
$property['REQUIRED'] = $property['REQUIED'];
}
$size1 = intval($property['SIZE1']);
$size2 = intval($property['SIZE2']);
$settings = array();
// TODO remove sale/include.php - $GLOBALS["SALE_FIELD_TYPES"]
switch ($property['TYPE']) {
case 'TEXT':
$property['TYPE'] = 'STRING';
if ($size1 > 0) {
$settings['SIZE'] = $size1;
}
break;
case 'TEXTAREA':
$property['TYPE'] = 'STRING';
$settings['MULTILINE'] = 'Y';
if ($size1 > 0) {
$settings['COLS'] = $size1;
}
if ($size2 > 0) {
$settings['ROWS'] = $size2;
}
break;
case 'CHECKBOX':
$property['TYPE'] = 'Y/N';
break;
case 'RADIO':
$property['TYPE'] = 'ENUM';
$settings['MULTIELEMENT'] = 'Y';
break;
case 'SELECT':
$property['TYPE'] = 'ENUM';
if ($size1 > 0) {
$settings['SIZE'] = $size1;
}
break;
case 'MULTISELECT':
$property['TYPE'] = 'ENUM';
$property['MULTIPLE'] = 'Y';
if ($size1 > 0) {
$settings['SIZE'] = $size1;
}
break;
case 'LOCATION':
// ID came, should store CODE
if (intval($property['DEFAULT_VALUE'])) {
$res = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=ID' => intval($property['DEFAULT_VALUE'])), 'select' => array('CODE')))->fetch();
if (is_array($res) && (string) $res['CODE'] != '') {
$property['DEFAULT_VALUE'] = $res['CODE'];
}
}
if ($size1 > 0) {
$settings['SIZE'] = $size1;
}
break;
}
$property['SETTINGS'] = $settings;
return $property;
}