Created
August 23, 2016 05:44
-
-
Save yakubenko/4a7330a001af6c0a683374afa2066e2f to your computer and use it in GitHub Desktop.
Bitrix get locations group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getLocationGroup() { | |
// из конфига config.php | |
global $defaultLocationsGroup; | |
$obCache = new CPHPCache; | |
if($obCache->InitCache(7200, "cities", "/klamas/all")) { | |
$locationsCache = $obCache->getVars(); | |
$locations = $locationsCache['cities']; | |
} elseif($obCache->StartDataCache()) { | |
$locations = array(); | |
$db_res = CSaleLocationGroup::GetLocationList(array("LOCATION_GROUP_ID"=>$defaultLocationsGroup)); | |
while($ar_res = $db_res->Fetch()) { | |
$locations[$ar_res["LOCATION_ID"]] = CSaleLocation::GetByID($ar_res["LOCATION_ID"]); | |
} | |
foreach($locations as $location) { | |
// РЕГИОН | |
if(empty($location['CITY_NAME_ORIG'])) { | |
$locations['REGIONS'][$location['REGION_ID']] = $location; | |
} else { | |
$locations['REGIONS'][$location['REGION_ID']]['CITIES'][$location['CITY_ID']] = $location; | |
} | |
unset($locations[$location['ID']]); | |
} | |
$obCache->EndDataCache(array('cities'=>$locations)); | |
} | |
return $locations; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment