本文整理汇总了PHP中Bitrix\Sale\Location\LocationTable::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP LocationTable::getList方法的具体用法?PHP LocationTable::getList怎么用?PHP LocationTable::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Sale\Location\LocationTable
的用法示例。
在下文中一共展示了LocationTable::getList方法的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: 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;
}
示例3: 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;
}
示例4: obtainDataTreeTrunk
protected function obtainDataTreeTrunk(&$cachedData)
{
// check for static tree
$forkItemFilter = false;
$res = Location\LocationTable::getList(array(
'group' => array('DEPTH_LEVEL'),
'select' => array('DEPTH_LEVEL', 'CNT'),
'order' => array('DEPTH_LEVEL' => 'asc')
));
$forkAtLevel = 0;
while($item = $res->fetch())
{
if($item['CNT'] < 2)
$forkAtLevel = $item['DEPTH_LEVEL'];
else
break;
}
if($forkAtLevel > 0)
$forkItemFilter = array('DEPTH_LEVEL' => $forkAtLevel);
// check for tree filtered by site
if($this->filterBySite && is_array($cachedData['TEMP']['CONNECTORS']) && !empty($cachedData['TEMP']['CONNECTORS']))
{
$dcp = Location\LocationTable::getDeepestCommonParent($cachedData['TEMP']['CONNECTORS'], array('select' => array('ID')))->fetch();
if(is_array($dcp) && intval($dcp['ID']))
$forkItemFilter = array('ID' => intval($dcp['ID']));
}
$cachedData['TREE_TRUNK'] = array();
if(is_array($forkItemFilter) && !empty($forkItemFilter)) // get fork item id
{
$res = Location\LocationTable::getPathToNodeByCondition($forkItemFilter, array(
'select' => array_merge($this->getNodeSelectFields(), array('LNAME' => 'NAME.NAME')),
'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID)
));
$res->addReplacedAliases(array('LNAME' => 'NAME'));
while($item = $res->fetch())
{
$cachedData['TREE_TRUNK'][] = $item;
}
}
}
示例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: AddLocationPart
private static function AddLocationPart($creat, $type, $parent, $sort)
{
$langs = self::getLanguages();
$types = self::getTypes();
$creatFlds = array();
if (is_numeric($creat)) {
// check whether location exists...
$res = Location\LocationTable::getList(array('filter' => array('=' . $type . '_ID' => $creat, 'TYPE_ID' => $types[$type]), 'select' => array('ID'), 'limit' => 1))->fetch();
if ($res['ID']) {
$parent = intval($res['ID']);
} else {
if ($type == 'COUNTRY') {
$res = self::GetCountryByID($creat);
} elseif ($type == 'REGION') {
$res = self::GetRegionByID($creat);
} elseif ($type == 'CITY') {
$res = self::GetCityByID($creat);
}
//!!!
if (!$res) {
// no such type exists, smth strange
throw new Exception('No such ' . $type);
}
// create location using type found
$creatFlds[$type . '_ID'] = $res['ID'];
$creatFlds['NAME'] = array();
foreach ($langs as $lid) {
if ($type == 'COUNTRY') {
$name = self::GetCountryLangByID($res['ID'], $lid);
} elseif ($type == 'REGION') {
$name = self::GetRegionLangByID($res['ID'], $lid);
} elseif ($type == 'CITY') {
$name = self::GetCityLangByID($res['ID'], $lid);
}
//!!!
$creatFlds['NAME'][$lid] = array('NAME' => $name['NAME'], 'SHORT_NAME' => $name['SHORT_NAME']);
}
}
} elseif (is_array($creat)) {
$creatFlds[$type . '_ID'] = self::getFreeId($type);
$creatFlds['NAME'] = array();
foreach ($creat as $lid => $name) {
$creatFlds['NAME'][$lid] = array('NAME' => $name['NAME'], 'SHORT_NAME' => $name['SHORT_NAME']);
}
}
if (!empty($creatFlds)) {
$creatFlds['PARENT_ID'] = $parent;
$creatFlds['TYPE_ID'] = $types[$type];
$creatFlds['CODE'] = rand(999, 99999999);
if ($sort !== false) {
$creatFlds['SORT'] = $sort;
}
$res = Location\LocationTable::add($creatFlds);
if (!$res->isSuccess()) {
throw new Exception('Cannot add location');
}
$parent = $res->getId();
Location\LocationTable::update($parent, array('CODE' => $parent));
}
return $parent;
}
示例7: find
/**
*
* $parameters is an ORM`s getList compatible array of parameters
*
*
*/
public static function find($parameters, $behaviour = array('FALLBACK_TO_NOINDEX_ON_NOTFOUND' => true, 'USE_INDEX' => true, 'USE_ORM' => true))
{
/////////////////////////////////
// parameter check and process
Assert::expectArray($parameters, '$parameters');
if (!is_array($behaviour)) {
$behaviour = array();
}
if (!isset($behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND'])) {
$behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND'] = true;
}
if (!isset($behaviour['USE_INDEX'])) {
$behaviour['USE_INDEX'] = true;
}
if (!isset($behaviour['USE_ORM'])) {
$behaviour['USE_ORM'] = true;
}
if (!isset($parameters['select'])) {
$parameters['select'] = array('ID');
}
Assert::expectArray($parameters['select'], '$parameters[select]');
if (isset($parameters['filter'])) {
Assert::expectArray($parameters['filter'], '$parameters[filter]');
// spikes, refactor later
if (isset($parameters['filter']['PHRASE']) || isset($parameters['filter']['=PHRASE'])) {
$key = isset($parameters['filter']['PHRASE']) ? 'PHRASE' : '=PHRASE';
$parameters['filter'][$key] = Assert::expectStringNotNull($parameters['filter'][$key], '$parameters[filter][' . $key . ']');
$parameters['filter'][$key] = str_replace('%', '', $parameters['filter'][$key]);
// cannot pass '%' to like
}
if (isset($parameters['filter']['SITE_ID']) || isset($parameters['filter']['=SITE_ID'])) {
$key = isset($parameters['filter']['SITE_ID']) ? 'SITE_ID' : '=SITE_ID';
$parameters['filter'][$key] = Assert::expectStringNotNull($parameters['filter'][$key], '$parameters[filter][' . $key . ']');
// stronger here
if (!Location\SiteLocationTable::checkLinkUsageAny($parameters['filter'][$key])) {
unset($parameters['filter'][$key]);
}
}
}
if (isset($parameters['limit'])) {
$parameters['limit'] = Assert::expectIntegerNonNegative($parameters['limit'], '$parameters[limit]');
}
if (isset($parameters['offset'])) {
$parameters['offset'] = Assert::expectIntegerNonNegative($parameters['offset'], '$parameters[offset]');
}
/////////////////////////////////
if (isset($parameters['filter']['PHRASE']) || isset($parameters['filter']['SITE_ID']) || isset($parameters['filter']['=PHRASE']) || isset($parameters['filter']['=SITE_ID']) || $behaviour['USE_ORM'] === false) {
if (static::checkIndexValid() && $behaviour['USE_INDEX']) {
$result = static::findUsingIndex($parameters);
if (!$behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND']) {
return $result;
} else {
$temporalBuffer = array();
while ($item = $result->fetch()) {
$temporalBuffer[] = $item;
}
if (empty($temporalBuffer)) {
return static::findNoIndex($parameters);
} else {
return new DB\ArrayResult($temporalBuffer);
}
}
} else {
return static::findNoIndex($parameters);
}
} else {
return Location\LocationTable::getList($parameters);
}
}
示例8: getLocationToCode
private static function getLocationToCode($arLocationTo)
{
$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"];
}
}
return $code;
}
示例9: array
}
}
}
}
elseif($_REQUEST['ACT'] == 'GET_ZIP_BY_LOC')
{
if(!intval($_REQUEST['LOC']))
$result['ERRORS'] = array('No location id passed');
else
{
$item = \Bitrix\Sale\Location\LocationTable::getList(
array(
'filter' => array(
'=ID' => intval($_REQUEST['LOC']),
'=EXTERNAL.SERVICE.CODE' => 'ZIP'
),
'select' => array(
'ZIP' => 'EXTERNAL.XML_ID'
)
)
)->fetch();
if(strlen($item['ZIP']))
$result['DATA']['ZIP'] = $item['ZIP'];
else
$result['ERRORS'] = array('None were found');
}
}
header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
print(CUtil::PhpToJSObject(array(
示例10: 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;
}
示例11: getSubpercentForStageCreateSearchIndex
protected function getSubpercentForStageCreateSearchIndex()
{
if ($this->getStep() == 0) {
$this->data['OFFSET'] = 0;
}
if (!isset($this->data['INDEX_LOCATION_COUNT'])) {
$item = Location\LocationTable::getList(array('select' => array('CNT'), 'filter' => ChainTable::getFilterForInitData(array('TYPES' => Finder::getIndexedTypes()))))->fetch();
$this->data['INDEX_LOCATION_COUNT'] = intval($item['CNT']);
}
return $this->getSubPercentByTotalAndDone($this->data['INDEX_LOCATION_COUNT'], $this->data['OFFSET']);
}
示例12: importFile
public static function importFile(&$descriptior)
{
$timeLimit = ini_get('max_execution_time');
if ($timeLimit < $descriptior['TIME_LIMIT']) {
set_time_limit($descriptior['TIME_LIMIT'] + 5);
}
$endTime = time() + $descriptior['TIME_LIMIT'];
if ($descriptior['STEP'] == 'rebalance') {
Location\LocationTable::resort();
Location\LocationTable::resetLegacyPath();
$descriptior['STEP'] = 'done';
}
if ($descriptior['STEP'] == 'import') {
if (!isset($descriptior['DO_SYNC'])) {
$res = \Bitrix\Sale\Location\LocationTable::getList(array('select' => array('CNT')))->fetch();
$descriptior['DO_SYNC'] = intval($res['CNT'] > 0);
}
if (!isset($descriptior['TYPES'])) {
$descriptior['TYPE_MAP'] = static::getTypeMap($descriptior['TYPE_FILE']);
$descriptior['TYPES'] = static::createTypes($descriptior['TYPE_MAP']);
$descriptior['SERVICE_MAP'] = static::getServiceMap($descriptior['SERVICE_FILE']);
$descriptior['SERVICES'] = static::getExistedServices();
}
$csvReader = new CSVReader();
$csvReader->LoadFile($descriptior['FILE']);
while (time() < $endTime) {
$block = $csvReader->ReadBlockLowLevel($descriptior['POS'], 100);
if (!count($block)) {
break;
}
foreach ($block as $item) {
if ($descriptior['DO_SYNC']) {
$id = static::checkLocationCodeExists($item['CODE']);
if ($id) {
$descriptior['CODES'][$item['CODE']] = $id;
continue;
}
}
// type
$item['TYPE_ID'] = $descriptior['TYPES'][$item['TYPE_CODE']];
unset($item['TYPE_CODE']);
// parent id
if (strlen($item['PARENT_CODE'])) {
if (!isset($descriptior['CODES'][$item['PARENT_CODE']])) {
$descriptior['CODES'][$item['PARENT_CODE']] = static::checkLocationCodeExists($item['PARENT_CODE']);
}
$item['PARENT_ID'] = $descriptior['CODES'][$item['PARENT_CODE']];
}
unset($item['PARENT_CODE']);
// ext
if (is_array($item['EXT'])) {
foreach ($item['EXT'] as $code => $values) {
if (is_array($values) && !empty($values)) {
if (!isset($descriptior['SERVICES'][$code])) {
$descriptior['SERVICES'][$code] = static::createService(array('CODE' => $code));
}
foreach ($values as $value) {
if (!strlen($value)) {
continue;
}
$item['EXTERNAL'][] = array('SERVICE_ID' => $descriptior['SERVICES'][$code], 'XML_ID' => $value);
}
}
}
}
unset($item['EXT']);
$res = Location\LocationTable::add($item, array('REBALANCE' => false, 'RESET_LEGACY' => false));
if (!$res->isSuccess()) {
throw new Main\SystemException('Cannot create location');
}
$descriptior['CODES'][$item['CODE']] = $res->getId();
}
}
if (!count($block)) {
unset($descriptior['CODES']);
$descriptior['STEP'] = 'rebalance';
}
}
return $descriptior['STEP'] == 'done';
}
示例13: elseif
}
$defCurrency = "EUR";
if ($lang == "ru") {
$defCurrency = "RUB";
} elseif ($lang == "en") {
$defCurrency = "USD";
}
$delivery = $wizard->GetVar("delivery");
$shopLocalization = $wizard->GetVar("shopLocalization");
WizardServices::IncludeServiceLang("step2.php", $lang);
if (COption::GetOptionString("eshop", "wizard_installed", "N", WIZARD_SITE_ID) != "Y") {
$locationGroupID = 0;
$arLocation4Delivery = array();
$arLocationArr = array();
if (\Bitrix\Main\Config\Option::get('sale', 'sale_locationpro_migrated', '') == 'Y') {
$res = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=TYPE.CODE' => 'COUNTRY'), 'select' => array('ID')));
while ($item = $res->fetch()) {
$arLocation4Delivery[] = array("LOCATION_ID" => $item["ID"], "LOCATION_TYPE" => "L");
}
} else {
$dbLocation = CSaleLocation::GetList(array(), array("LID" => $lang));
while ($arLocation = $dbLocation->Fetch()) {
$arLocation4Delivery[] = array("LOCATION_ID" => $arLocation["ID"], "LOCATION_TYPE" => "L");
$arLocationArr[] = $arLocation["ID"];
}
$dbGroup = CSaleLocationGroup::GetList();
if ($arGroup = $dbGroup->Fetch()) {
$arLocation4Delivery[] = array("LOCATION_ID" => $arGroup["ID"], "LOCATION_TYPE" => "G");
} else {
$groupLang = array(array("LID" => "en", "NAME" => "Group 1"));
if ($bRus) {
示例14: elseif
$arRes["LOCATION_ID"] = $vars["ID"];
endwhile;
}
elseif(isset($_POST["getAddressData"])){
include($_SERVER["DOCUMENT_ROOT"].'/local/components/zakrepi/sale.order.ajax/functions.php');
$arResult = Array();
getJsUserAddress($arResult, $USER->GetID());
$arRes = $arResult["JS_USER_ADDRESS"];
}
elseif(isset($_POST["CITY_NAME"])&& CModule::IncludeModule("useraddress") && CModule::IncludeModule("sale")){
$city_name = "%".$_POST["CITY_NAME"]."%";
$res = \Bitrix\Sale\Location\LocationTable::getList(array(
'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID,"NAME_RU"=>$city_name,"!CITY_ID"=>''),
'select' => array('*', 'NAME_RU' => 'NAME.NAME', 'TYPE_CODE' => 'TYPE.CODE')
));
$arRes["LOCATION_ID"] = array();
$i=0;
while($item = $res->Fetch())
{
$ID = CSaleLocation::getLocationIDbyCODE($item['CODE']);
$arVal = CSaleLocation::GetByID( $ID, LANGUAGE_ID);
//$arRes["LOCATION_ID"][$i] = $item;
$arRes["LOCATION_ID"][$i]['ID'] = $item['CITY_ID'];
$arRes["LOCATION_ID"][$i]['NAME'] = $item['NAME_RU'];
$arRes["LOCATION_ID"][$i]['REGION'] = $arVal['REGION_NAME_LANG'];
$i++;
}
示例15: initializeData
public function initializeData()
{
$dbConnection = Main\HttpApplication::getConnection();
$res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'DEPTH_LEVEL', 'SORT'), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $this->procData['OFFSET']));
$cnt = 0;
while ($item = $res->fetch()) {
$name = Location\Name\LocationTable::getList(array('select' => array('NAME'), 'filter' => array('=LOCATION_ID' => $item['ID'], '=LANGUAGE_ID' => 'ru')))->fetch();
if ($item['DEPTH_LEVEL'] < $this->procData['DEPTH']) {
$newPC = array();
foreach ($this->procData['PATH'] as $dl => $id) {
if ($dl >= $item['DEPTH_LEVEL']) {
break;
}
$newPC[$dl] = $id;
}
$this->procData['PATH'] = $newPC;
}
$this->procData['PATH'][$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']);
$this->procData['DEPTH'] = $item['DEPTH_LEVEL'];
if (is_array($this->procData['ALLOWED_TYPES']) && in_array($item['TYPE_ID'], $this->procData['ALLOWED_TYPES'])) {
$data = array('LOCATION_ID' => $item['ID'], 'RELEVANCY' => $this->procData['TYPE_SORT'][$item['TYPE_ID']]);
$wordsAdded = array();
$k = 1;
foreach ($this->procData['PATH'] as &$pathItem) {
if (!isset($pathItem['WORDS'])) {
$sql = "\n\t\t\t\t\t\t\tselect WS.POSITION from " . WordTable::getTableNameWord2Location() . " WL\n\t\t\t\t\t\t\t\tinner join " . WordTable::getTableName() . " WS on WL.WORD_ID = WS.ID\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tWL.LOCATION_ID = '" . intval($pathItem['ID']) . "'\n\t\t\t\t\t\t";
$wordRes = $dbConnection->query($sql);
$pathItem['WORDS'] = array();
while ($wordItem = $wordRes->fetch()) {
$pathItem['WORDS'][] = $wordItem['POSITION'];
}
$pathItem['WORDS'] = array_unique($pathItem['WORDS']);
}
foreach ($pathItem['WORDS'] as $position) {
if (!isset($wordsAdded[$position])) {
$this->indexInserter->insert(array_merge(array('POSITION' => $position), $data));
$wordsAdded[$position] = true;
}
}
}
unset($pathItem);
}
$cnt++;
}
$this->indexInserter->flush();
$this->procData['OFFSET'] += self::STEP_SIZE;
return !$cnt;
}