define('STOP_STATISTICS', true);
define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC', 'Y');
define('DisableEventsCheck', true);
define('BX_SECURITY_SHOW_MESSAGE', true);
define('NOT_CHECK_PERMISSIONS', true);
$_SERVER['DOCUMENT_ROOT'] = dirname(__DIR__, 1);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');
CModule::IncludeModule('iblock');
$sitemap_catalog = [];
$sitemap_all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, ], false, false, [ "CODE", "PROPERTY_UID" ] );
while($sitemap_all_brands_search_ob = $sitemap_all_brands_search_res->GetNextElement())
{
$brand = $sitemap_all_brands_search_ob->GetFields();
$brand['MODELS'] = [];
$sitemap_catalog[$brand['PROPERTY_UID_VALUE']] = $brand;
}
$sitemap_all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, ], false, false, [ "CODE", "PROPERTY_BRAND_UID"] );
while($sitemap_all_models_search_ob = $sitemap_all_models_search_res->GetNextElement())
{
$model = $sitemap_all_models_search_ob->GetFields();
$model['PROPERTIES'] = $sitemap_all_models_search_ob->GetProperties();
array_push($sitemap_catalog[$model['PROPERTY_BRAND_UID_VALUE']]['MODELS'], $model);
}
$url = "https://".SITE_SERVER_NAME."/catalog";
$lastmod = date(DATE_W3C);
$sitemap_catalog_string = "\n\n";
foreach($sitemap_catalog AS $brand)
{
$sitemap_catalog_string .= "".$url."/".$brand['CODE']."/"."".$lastmod.""."\n";
foreach($brand['MODELS'] AS $model)
{
$sitemap_catalog_string .= "".$url."/".$brand['CODE']."/".$model['CODE']."/"."".$lastmod.""."\n";
}
}
$sitemap_car_search_res = CIBlockElement::GetList( [ "NAME" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, ], false, [], [] );
while($sitemap_car_search_ob = $sitemap_car_search_res->GetNextElement())
{
$car_existed = $sitemap_car_search_ob->GetFields();
$sitemap_catalog_string .= "https://".SITE_SERVER_NAME.$car_existed['DETAIL_PAGE_URL']."".$lastmod.""."\n";
}
$sitemap_catalog_string .= ""."\n";
file_put_contents("/home/bitrix/www/sitemap-catalog.xml", $sitemap_catalog_string);
$chunk = "https://www.evoleasing.ru/sitemap-catalog.xml".date(DATE_W3C)."";
$sitemap_index = file_get_contents("/home/bitrix/www/sitemap.xml");
$sitemap_index = str_replace(">", ">\n", $sitemap_index);
$sitemap_index = str_replace("", $chunk, $sitemap_index);
$sitemap_index = str_replace("\n", "", $sitemap_index);
file_put_contents("/home/bitrix/www/sitemap.xml", $sitemap_index);
die();
?>