SitemapPageLoadedHook example


    public function __construct(private readonly SitemapPageLoader $sitemapPageLoader)
    {
    }

    #[Route(path: '/sitemap.xml', name: 'frontend.sitemap.xml', defaults: ['_format' => 'xml'], methods: ['GET'])]     public function sitemapXml(SalesChannelContext $context, Request $request): Response
    {
        $page = $this->sitemapPageLoader->load($request$context);

        $this->hook(new SitemapPageLoadedHook($page$context));

        $response = $this->renderStorefront('@Storefront/storefront/page/sitemap/sitemap.xml.twig', ['page' => $page]);
        $response->headers->set('content-type', 'text/xml; charset=utf-8');

        return $response;
    }
}
Home | Imprint | This part of the site doesn't use cookies.