aggregations programs sitemap

This commit is contained in:
merelendor 2024-09-23 18:44:45 +00:00
parent b9685072a6
commit aeebf969b6

View File

@ -2507,15 +2507,15 @@ if(!in_array("simulate", $GLOBALS['argv']))
$sitemap_catalog_string .= "</urlset>"."\n";
file_put_contents("/home/bitrix/www/sitemap-catalog.xml", $sitemap_catalog_string);
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap-catalog.xml", $sitemap_catalog_string);
$chunk = "<sitemap><loc>https://www.evoleasing.ru/sitemap-catalog.xml</loc><lastmod>".date(DATE_W3C)."</lastmod></sitemap></sitemapindex>";
$chunk = "<sitemap><loc>https://www.evoleasing.ru/sitemap-catalog.xml</loc><lastmod>".date( DATE_W3C )."</lastmod></sitemap></sitemapindex>";
$sitemap_index = file_get_contents("/home/bitrix/www/sitemap.xml");
$sitemap_index = file_get_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml");
$sitemap_index = str_replace(">", ">\n", $sitemap_index);
$sitemap_index = str_replace("</sitemapindex>", $chunk, $sitemap_index);
$sitemap_index = str_replace("\n", "", $sitemap_index);
file_put_contents("/home/bitrix/www/sitemap.xml", $sitemap_index);
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml", $sitemap_index);
/* sitemap catalog file end -------------------------------------------------------------*/
@ -2583,15 +2583,83 @@ if(!in_array("simulate", $GLOBALS['argv']))
$sitemap_regions_string .= "</urlset>"."\n";
file_put_contents("/home/bitrix/www/sitemap-regions.xml", $sitemap_regions_string);
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap-regions.xml", $sitemap_regions_string);
$chunk = "<sitemap><loc>https://www.evoleasing.ru/sitemap-regions.xml</loc><lastmod>".date(DATE_W3C)."</lastmod></sitemap></sitemapindex>";
$sitemap_index = file_get_contents("/home/bitrix/www/sitemap.xml");
$sitemap_index = file_get_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml");
$sitemap_index = str_replace(">", ">\n", $sitemap_index);
$sitemap_index = str_replace("</sitemapindex>", $chunk, $sitemap_index);
$sitemap_index = str_replace("\n", "", $sitemap_index);
file_put_contents("/home/bitrix/www/sitemap.xml", $sitemap_index);
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml", $sitemap_index);
/* sitemap aggregations programs file start -------------------------------------------------------------*/
$url = "https://".SITE_SERVER_NAME."/programs";
$lastmod = date(DATE_W3C);
$sitemap_program_aggregations_string = "<?xml version='1.0' encoding='UTF-8'?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$sitemap_program_aggregations_string .= "<url><loc>".$url."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
$programs = [[
"ROOT_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_SPECIAL,
"ROOT_CHUNK" => IBLOCK_ID_PROGRAMS_AGGREGATION_SPECIAL_CHUNK,
"BRANDS_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_BRANDS_SPECIAL,
"RULES_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_RULES_SPECIAL,
], [
"ROOT_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_CARGO,
"ROOT_CHUNK" => IBLOCK_ID_PROGRAMS_AGGREGATION_CARGO_CHUNK,
"BRANDS_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_BRANDS_CARGO,
"RULES_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_RULES_CARGO,
]];
foreach($programs AS $program)
{
$sitemap_program_aggregations_root = CIBlockSection::GetList([ "NAME" => "ASC" ], [ "IBLOCK_ID" => $program['ROOT_ID'] ], false, [], false);
while ($sitemap_program_aggregations_root_section = $sitemap_program_aggregations_root->GetNext())
{
$sitemap_program_aggregations_string .= "<url><loc>".$url."/".$program['ROOT_CHUNK']."/".$sitemap_program_aggregations_root_section['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
$sitemap_program_aggregations_entries = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "IBLOCK_ID" => $program['ROOT_ID'], "SECTION_ID" => intval($sitemap_program_aggregations_root_section['ID']), "ACTIVE" => "Y" ], false, [ "nTopCount" => 1000 ], [], );
while($sitemap_program_aggregations_entry_ob = $sitemap_program_aggregations_entries->GetNextElement())
{
$sitemap_program_aggregations_entry = $sitemap_program_aggregations_entry_ob->GetFields();
$sitemap_program_aggregations_string .= "<url><loc>".$url."/".$program['ROOT_CHUNK']."/".$sitemap_program_aggregations_root_section['CODE']."/".$sitemap_program_aggregations_entry['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
}
}
$sitemap_program_aggregations_brands = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "IBLOCK_ID" => $program['BRANDS_ID'], "ACTIVE" => "Y" ], false, [ "nTopCount" => 1000 ], [], );
while($sitemap_program_aggregations_brand_ob = $sitemap_program_aggregations_brands->GetNextElement())
{
$sitemap_program_aggregations_brand = $sitemap_program_aggregations_brand_ob->GetFields();
$sitemap_program_aggregations_string .= "<url><loc>".$url."/".$program['ROOT_CHUNK']."/".$sitemap_program_aggregations_brand['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
$sitemap_program_aggregations_brand_types = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "IBLOCK_ID" => $program['RULES_ID'], "PROPERTY_VEHICLE_BRAND" => $sitemap_program_aggregations_brand['ID'], "ACTIVE" => "Y" ], false, [ "nTopCount" => 1000 ], [], );
while($sitemap_program_aggregations_type_ob = $sitemap_program_aggregations_brand_types->GetNextElement())
{
$sitemap_program_aggregations_brand_type = $sitemap_program_aggregations_type_ob->GetFields();
$sitemap_program_aggregations_brand_type['PROPERTIES'] = $sitemap_program_aggregations_type_ob->GetProperties();
if(!empty($sitemap_program_aggregations_brand_type['PROPERTIES']['VEHICLE_TYPE']['VALUE']))
{
$sitemap_program_aggregations_brand_type_related = get_related($program['ROOT_ID'], $sitemap_program_aggregations_brand_type['PROPERTIES']['VEHICLE_TYPE']['VALUE']);
$sitemap_program_aggregations_string .= "<url><loc>".$url."/".$program['ROOT_CHUNK']."/".$sitemap_program_aggregations_brand['CODE']."/".$sitemap_program_aggregations_brand_type_related['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
}
}
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap-programs.xml", $sitemap_program_aggregations_string);
$chunk = "<sitemap><loc>https://www.evoleasing.ru/sitemap-programs.xml</loc><lastmod>".date(DATE_W3C)."</lastmod></sitemap></sitemapindex>";
$sitemap_index = file_get_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml");
$sitemap_index = str_replace(">", ">\n", $sitemap_index);
$sitemap_index = str_replace("</sitemapindex>", $chunk, $sitemap_index);
$sitemap_index = str_replace("\n", "", $sitemap_index);
file_put_contents($_SERVER['DOCUMENT_ROOT']."/sitemap.xml", $sitemap_index);
/* sitemap aggregations programs file end -------------------------------------------------------------*/
}
/* sitemap regions file end -------------------------------------------------------------*/
@ -2607,12 +2675,8 @@ if(!in_array("simulate", $GLOBALS['argv']) && !in_array("debug", $argv))
]);
}
//print "----------bitrix_enabled_modifications----------\n";
//print_r($bitrix_enabled_modifications);
//print "--------------------\n";
print "-----current_representation-----\n\n";
print_r($current_representation);
//print "-----current_representation-----\n\n";
//print_r($current_representation);
foreach($current_representation AS $brand_uid => $brand)
{
@ -2658,23 +2722,6 @@ foreach($current_representation AS $brand_uid => $brand)
}
}
//print "-----current_representation-----\n\n";
//foreach($current_representation AS $k => $v)
//{
// print "[ ".$k." ]\n";
//}
/*
print "-----bitrix_existed_brands\n\n";
print_r($bitrix_existed_brands);
print "-----bitrix_enabled_brands\n\n";
print_r($bitrix_enabled_brands);
print "-----bitrix_hidden_brands\n\n";
print_r($bitrix_hidden_brands);
*/
die();
?>