75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?
|
|
//$_SERVER["DOCUMENT_ROOT"] = __DIR__;
|
|
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');
|
|
|
|
$catalog = [];
|
|
|
|
$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 8, "ACTIVE" => "Y" ], false, false, [ "CODE", "PROPERTY_UID" ] );
|
|
while($all_brands_search_ob = $all_brands_search_res->GetNextElement())
|
|
{
|
|
$brand = $all_brands_search_ob->GetFields();
|
|
$brand['MODELS'] = [];
|
|
|
|
$catalog[$brand['PROPERTY_UID_VALUE']] = $brand;
|
|
}
|
|
|
|
$all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 9, "ACTIVE" => "Y" ], false, false, [ "CODE", "PROPERTY_BRAND_UID"] );
|
|
while($all_models_search_ob = $all_models_search_res->GetNextElement())
|
|
{
|
|
$model = $all_models_search_ob->GetFields();
|
|
$model['PROPERTIES'] = $all_models_search_ob->GetProperties();
|
|
|
|
array_push($catalog[$model['PROPERTY_BRAND_UID_VALUE']]['MODELS'], $model);
|
|
|
|
//print_r($model);
|
|
//array_push( $bitrix_existed_models, $model_search['PROPERTIES']['UID']['VALUE'] );
|
|
}
|
|
|
|
//print_r($catalog);
|
|
|
|
//7f7534ad-5382-469c-8e40-f77267fb5644
|
|
|
|
$url = "https://".SITE_SERVER_NAME."/catalog";
|
|
$lastmod = date(DATE_W3C);
|
|
|
|
$strBegin = "<?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";
|
|
|
|
foreach($catalog AS $brand)
|
|
{
|
|
//print ;
|
|
//print "\n";
|
|
//"\t".
|
|
$strBegin .= "<url><loc>".$url."/".$brand['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
|
|
|
|
foreach($brand['MODELS'] AS $model)
|
|
{
|
|
//print "\t";
|
|
//print $url."/".$brand['CODE']."/".$model['CODE']."/";
|
|
//print "\n";
|
|
//"\t"."\t".
|
|
$strBegin .= "<url><loc>".$url."/".$brand['CODE']."/".$model['CODE']."/"."</loc><lastmod>".$lastmod."</lastmod></url>"."\n";
|
|
}
|
|
|
|
/*
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url><loc>https://evo.quickcode.ru/</loc><lastmod>2022-03-29T15:01:44+03:00</lastmod></url>
|
|
*/
|
|
}
|
|
$strBegin .= "</urlset>"."\n";
|
|
|
|
file_put_contents("../sitemap-catalog.xml", $strBegin);
|
|
//print $strBegin;
|
|
|
|
die();
|
|
|
|
?>
|