private readonly SystemConfigService
$systemConfigService,
private readonly SitemapExporterInterface
$sitemapExporter ) { } #[Route(path: '/store-api/sitemap', name: 'store-api.sitemap', methods: ['GET', 'POST'])]
public function load(Request
$request, SalesChannelContext
$context): SitemapRouteResponse
{ $sitemaps =
$this->sitemapLister->
getSitemaps($context);
if ($this->systemConfigService->
getInt('core.sitemap.sitemapRefreshStrategy'
) !== SitemapExporterInterface::STRATEGY_LIVE
) { return new SitemapRouteResponse(new SitemapCollection($sitemaps));
} // Close session to prevent session locking from waiting in case there is another request coming in
if ($request->
hasSession() &&
session_status() === \PHP_SESSION_ACTIVE
) { $request->
getSession()->
save();
} try { $this->
generateSitemap($context, true
);
} catch (AlreadyLockedException
) { // Silent catch, lock couldn't be acquired. Some other process already generates the sitemap.