- Issue created by @eduardo morales alberti
- 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
The QueueWorker queue each sitemap on \Drupal\simple_sitemap\Queue\QueueWorker::queue
Could be a good place to divide the sitemaps under conditions (languages, content types...).
public function queue($sitemaps = []): QueueWorker { $empty_variants = array_fill_keys(array_keys($sitemaps), TRUE); $all_data_sets = []; foreach ($sitemaps as $variant => $sitemap) { if ($sitemap->isEnabled()) { foreach ($sitemap->getType()->getUrlGenerators() as $url_generator_id => $url_generator) { // @todo Automatically set sitemap. foreach ($url_generator->setSitemap($sitemap)->getDataSets() as $data_set) { unset($empty_variants[$variant]); $all_data_sets[] = [ 'data' => $data_set, 'sitemap' => $variant, 'url_generator' => $url_generator_id, ]; if (count($all_data_sets) === self::REBUILD_QUEUE_CHUNK_ITEM_SIZE) { $this->queueElements($all_data_sets); $all_data_sets = []; } } } } } if (!empty($all_data_sets)) { $this->queueElements($all_data_sets); } $this->getQueuedElementCount(TRUE); // Remove all sitemap content of variants which did not yield any queue // elements. foreach ($empty_variants as $variant => $is_empty) { $sitemaps[$variant]->deleteContent(); } return $this; }
Example:
$all_data_sets[] = [ 'data' => $data_set, 'sitemap' => $variant, 'variant' => [ 'type' => 'product', 'language' => 'es-es', ], 'url_generator' => $url_generator_id, ];
- Status changed to Fixed
2 months ago 9:24am 21 October 2024 - 🇷🇺Russia walkingdexter
There is no need to divide sitemaps by language. You can simply divide them by content type. URLs for other languages will be automatically included.
Automatically closed - issue fixed for 2 weeks with no activity.