====== Подгрузка адреса ====== queryBuilder() ->where('name', 'like', '%' . $sQuery . '%') ->where('shop_country_id', '=', Core_Array::getGet('shop_country_id')); $aoShopCountryLocations = $oShopCountryLocations->findAll(); foreach ($aoShopCountryLocations as $oShopCountryLocation) { $aJSON['suggestions'][] = array( 'value' => $oShopCountryLocation->name, 'id' => $oShopCountryLocation->id ); } } elseif(Core_Array::getGet('dataType') == 'shop_country_location_city') { $oShopCountryLocationCities = Core_Entity::factory('shop_country_location_city'); $oShopCountryLocationCities->queryBuilder() ->where('name', 'like', '%' . $sQuery . '%') ->where('shop_country_location_id', '=', Core_Array::getGet('shop_country_location_id')); $aoShopCountryLocationCities = $oShopCountryLocationCities->findAll(); foreach($aoShopCountryLocationCities as $oShopCountryLocationCity) { $aoShopCountryLocationCityAreas = Core_Entity::factory('shop_country_location_city_area')->getAllByShop_Country_Location_City_Id($oShopCountryLocationCity->id); $aJSON['suggestions'][] = array( 'value' => $oShopCountryLocationCity->name, 'id' => $oShopCountryLocationCity->id, 'areas' => count($aoShopCountryLocationCityAreas) ); } } elseif(Core_Array::getGet('dataType') == 'shop_country_location_city_area') { $oShopCountryLocationCityAreas = Core_Entity::factory('shop_country_location_city_area'); $oShopCountryLocationCityAreas->queryBuilder() ->where('name', 'like', '%' . $sQuery . '%') ->where('shop_country_location_city_id', '=', Core_Array::getGet('shop_country_location_city_id')); $aoShopCountryLocationCityAreas = $oShopCountryLocationCityAreas->findAll(); foreach($aoShopCountryLocationCityAreas as $oShopCountryLocationCityArea) { $aJSON['suggestions'][] = array( 'value' => $oShopCountryLocationCityArea->name, 'id' => $oShopCountryLocationCityArea->id ); } } Core_Page::instance()->response ->status(200) ->header('Pragma', 'no-cache') ->header('Cache-Control', 'private, no-cache') ->header('Vary', 'Accept') ->header('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT') ->header('X-Powered-By', 'HostCMS') ->header('Content-Disposition', 'inline; filename="files.json"'); Core_Page::instance()->response ->body(json_encode($aJSON)) ->header('Content-type', 'application/json; charset=utf-8'); Core_Page::instance()->response ->sendHeaders() ->showBody(); exit(); } } }