• Модуль: seo
  • Путь к файлу: ~/bitrix/modules/seo/lib/Sitemap/Generator.php
  • Класс: BitrixSeoSitemapGenerator
  • Вызов: Generator::runIndex
protected function runIndex(): bool
{
	$result = true;

	RuntimeTable::clearByPid($this->sitemapId);

	$sitemapFile = new FileIndex($this->sitemapData['SETTINGS']['FILENAME_INDEX'], $this->getSitemapSettings());
	$xmlFiles = [];
	if (count($this->state['XML_FILES']) > 0)
	{
		foreach ($this->state['XML_FILES'] as $xmlFile)
		{
			$xmlFiles[] = new IOFile(
				IOPath::combine(
					$sitemapFile->getSiteRoot(),
					$xmlFile
				), $this->sitemapData['SITE_ID']
			);
		}
	}
	$sitemapFile->createIndex($xmlFiles);

	$existedSitemaps = [];
	if ($this->sitemapData['SETTINGS']['ROBOTS'] == 'Y')
	{
		$sitemapUrl = $sitemapFile->getUrl();

		$robotsFile = new RobotsFile($this->sitemapData['SITE_ID']);
		$robotsFile->addRule([
			RobotsFile::SITEMAP_RULE, $sitemapUrl
		]);

		$sitemapLinks = $robotsFile->getRules(RobotsFile::SITEMAP_RULE);
		if (count($sitemapLinks) > 1) // 1 - just added rule
		{
			foreach ($sitemapLinks as $rule)
			{
				if ($rule[1] != $sitemapUrl)
				{
					$existedSitemaps[] = $rule[1];
				}
			}
		}
	}
	// todo: need show message about robots.txt
	// if (isset($arExistedSitemaps) && count($arExistedSitemaps) > 0)
	// {
	// 	echo BeginNote(), Loc::getMessage('SEO_SITEMAP_RUN_ROBOTS_WARNING', array(
	// 		"#SITEMAPS#" => "
  • " . implode("
  • ", $arExistedSitemaps) . "
  • ", // "#LANGUAGE_ID#" => LANGUAGE_ID, // "#SITE_ID#" => $arSitemap['SITE_ID'], // )); // } $this->step = Step::STEPS[Step::STEP_INDEX]; $this->statusMessage = Loc::getMessage('SITEMAP_RUN_FINISH'); return $result; }