Search code examples
symfonyshopwareshopware6

Landingpage missing in Sitemap.xml in Shopware 6


I have recently created a Landingpage and it does not appear to be listed in the sitemap. Refreshing indexes and generating sitemaps manually did not do the trick.

Does anyone have an Idea how to fix this or where to start?


Solution

  • For debugging I suggest to the mode "live". The sitemaps are generated when requesting /sitemap.xml. Now you can set a breakpoint in

    vendor/shopware/core/Content/Sitemap/Service/SitemapExporter.php:47

    In my case I could reproduce your issue.

    There is a loop over URL providers:

    foreach ($this->urlProvider as $urlProvider) {
    

    You see the HomeUrlProvider is called and then \Shopware\Core\Content\Sitemap\Provider\CategoryUrlProvider.

    The \Shopware\Core\Content\Sitemap\Provider\CategoryUrlProvider::getUrls only fetches real categories. Even landing pages are listed under categories in the admin panel, they are stored in the landing_page_* tables and so are not covered by this URL provider.

    There seems no UrlProvider specifically for Landingpages (as of 6.5.3.3 where I checked).

    So this might be intended that landing pages are not listed in the Sitemap?

    Classes extending the AbstratUrlProvider

    You could - as a workaround - add custom URLs via config/packages/z-shopware.yaml

    shopware:
        sitemap:
            custom_urls:
                - url: 'my-landing-page'
                  lastMod: '2023-10-07 21:59:43'
                  changeFreq: weekly
                  salesChannelId: 7a0794721cba448d87e0a7c752ffedff
    

    Drawback is that you have to specify the lastMod date manually.