['period' => '0 2 * * *'], ]; } /** * Cron: Формирование файла Sitemap.xml * Рекомендуемый период: раз в сутки * @return void */ public function cronSitemapXML() { if (! $this->isCron()) { return; } $file = 'sitemap'; if ($this->robotsEnabled(true)) { # новая схема $path = $this->pathSEO(); # путь для хранения файлов $url = $this->urlSEO(); if (Geo::urlType() == Geo::URL_SUBDOMAIN) { # для основного домена $geo = ['id' => 0, 'city' => '', 'region1' => '', 'keyword' => '']; $this->generateSitemapXMLSubdomains($geo, $file, $path, $url); # для поддоменов, в которых есть объявления $counters = Listings::model()->itemsCountByFilter([ 'cat_id' => 0, 'delivery' => 0, ':reg' => 'region_id > 0', ], ['region_id'], false); foreach ($counters as $v) { $region = Geo::regionData($v['region_id']); if (empty($region)) { continue; } $geo = ['id' => 0, 'city' => '', 'region1' => '', 'keyword' => '']; $geo = array_merge($geo, Geo::regionParents($region)['keys'] ?? []); $this->generateSitemapXMLSubdomains( $geo, $region['keyword'] . '_sitemap', $path, $this->urlSEO($region['keyword']) ); } } else { # для основного домена $this->generateSitemapXMLSingleDomain($file, $path, $url); } } else { # старая схема $this->generateSitemapXMLSingleDomain($file, $this->app->path(''), $this->app->url('')); } } }