From 522d24869b68ed2a6e4a68d542725037c521517f Mon Sep 17 00:00:00 2001 From: merelendor Date: Thu, 1 Dec 2022 04:06:35 +0300 Subject: [PATCH] update for sitemap generation for catalog section --- .htaccess | 1 + local/catalog_sitemap_generation.php | 31 +++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.htaccess b/.htaccess index 693b941..2871abe 100644 --- a/.htaccess +++ b/.htaccess @@ -6811,6 +6811,7 @@ RewriteRule ^car/hyundai-tucson-lifestyle-plus-plus-smart-sense-2-0d-8at-4wd/$ h RewriteRule ^car/hyundai-tucson-family-plus-2-0d-8at-4wd/$ https://www.evoleasing.ru/car/hyundai-tucson-family-plus-2-0d-8at-4wd-2020/ [R=301,NE,NC,L] RewriteRule ^car/hyundai-tucson-lifestyle-plus-2-0d-8at-4wd/$ https://www.evoleasing.ru/car/hyundai-tucson-lifestyle-plus-2-0d-8at-4wd-2020/ [R=301,NE,NC,L] RewriteRule ^car/hyundai-tucson-lifestyle-plus-plus-navigation-2-0d-8at-4wd/$ https://www.evoleasing.ru/car/hyundai-tucson-lifestyle-plus--plus--navigation-2-0d-8at-4wd-2020/ [R=301,NE,NC,L] +RewriteRule ^car/hyundai-tucson-lifestyle-smart-sense-2-0-6at-2wd/$ https://www.evoleasing.ru/car/hyundai-tucson-lifestyle--plus--smart-sense-2-0-6at-2wd-2020/ [R=301,NE,NC,L] RewriteRule ^car/mini-5-door-cooper-classic/$ https://www.evoleasing.ru/car/mini-5-door-cooper-classic-2021/ [R=301,NE,NC,L] RewriteRule ^car/mini-5-door-cooper-jcw/$ https://www.evoleasing.ru/car/mini-5-door-cooper-jcw-2021/ [R=301,NE,NC,L] RewriteRule ^car/mini-5-door-cooper-essential/$ https://www.evoleasing.ru/car/mini-5-door-cooper-essential-2021/ [R=301,NE,NC,L] diff --git a/local/catalog_sitemap_generation.php b/local/catalog_sitemap_generation.php index 0b9c543..402f815 100644 --- a/local/catalog_sitemap_generation.php +++ b/local/catalog_sitemap_generation.php @@ -13,7 +13,7 @@ CModule::IncludeModule('iblock'); $catalog = []; -$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 8, "ACTIVE" => "Y" ], false, false, [ "CODE", "PROPERTY_UID" ] ); +$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, ], false, false, [ "CODE", "PROPERTY_UID" ] ); while($all_brands_search_ob = $all_brands_search_res->GetNextElement()) { $brand = $all_brands_search_ob->GetFields(); @@ -22,7 +22,7 @@ while($all_brands_search_ob = $all_brands_search_res->GetNextElement()) $catalog[$brand['PROPERTY_UID_VALUE']] = $brand; } -$all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 9, "ACTIVE" => "Y" ], false, false, [ "CODE", "PROPERTY_BRAND_UID"] ); +$all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, ], false, false, [ "CODE", "PROPERTY_BRAND_UID"] ); while($all_models_search_ob = $all_models_search_res->GetNextElement()) { $model = $all_models_search_ob->GetFields(); @@ -45,31 +45,34 @@ $strBegin = "\n".$lastmod.""."\n"; foreach($brand['MODELS'] AS $model) { - //print "\t"; - //print $url."/".$brand['CODE']."/".$model['CODE']."/"; - //print "\n"; - //"\t"."\t". $strBegin .= "".$url."/".$brand['CODE']."/".$model['CODE']."/"."".$lastmod.""."\n"; } +} - /* - - - https://evo.quickcode.ru/2022-03-29T15:01:44+03:00 - */ +$car_search_res = CIBlockElement::GetList( [ "NAME" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, ], false, [], [] ); +while($car_search_ob = $car_search_res->GetNextElement()) +{ + $car_existed = $car_search_ob->GetFields(); + $strBegin .= "https://".SITE_SERVER_NAME.$car_existed['DETAIL_PAGE_URL']."".$lastmod.""."\n"; } $strBegin .= ""."\n"; file_put_contents("../sitemap-catalog.xml", $strBegin); //print $strBegin; +$chunk = "https://www.evoleasing.ru/sitemap-catalog.xml".date(DATE_W3C).""; + +$sitemap_index = file_get_contents("../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("../sitemap.xml", $sitemap_index); + + die(); ?> \ No newline at end of file