Geta / geta-optimizely-sitemaps

Search engine sitemaps.xml for Optimizely CMS 12 and Commerce 14
Apache License 2.0
11 stars 15 forks source link

Commerce Settings #93

Open jaymarvels opened 1 year ago

jaymarvels commented 1 year ago

Are there any additional configuration to get this to work with commerce apart from adding:

services.AddSitemapsCommerce();

In the configuration docs (https://github.com/Geta/geta-optimizely-sitemaps/blob/master/docs/editor-guide.md) it talks about the format and how its currently standard or mobile. If I do check the "standard and commerce" option and run the scheduled job my commerce product pages still do not show in the sitemap.xml.

Is something missing?

jaymarvels commented 1 year ago

@marisks Any input?

marisks commented 1 year ago

As I remember, it is enough to follow configuration documentation here: https://github.com/Geta/geta-optimizely-sitemaps/tree/master#configuration So call AddSitemaps, AddSitemapsCommerce, and make sure that razor pages are mapped.

jaymarvels commented 1 year ago

@marisks Yeah unfortunately its not working. I am guessing it could be due to it being multi site, multi language, multi catalog it can't get the correct one.

If I create my own sitemap and commerce generator by implementing the public virtual member, eg:

public class StandardAndCommerceSitemapXmlGenerator : CommerceSitemapXmlGenerator, ICommerceAndStandardSitemapXmlGenerator
{
//
}

And just use the default from the repo as an override:

        protected override IEnumerable<XElement> GetSitemapXmlElements()
        {
            var rootContentReference = _referenceConverter.GetRootLink();

            if (SitemapData.RootPageId != Constants.DefaultRootPageId)
            {
                rootContentReference = new ContentReference(SitemapData.RootPageId)
                {
                    ProviderName = "CatalogContent"
                };
            }

            var descendants = ContentRepository.GetDescendents(rootContentReference);

            return GenerateXmlElements(descendants);
        }

Then descendants is always empty.

marisks commented 1 year ago

Have you configured RootPageId for the catalog you want to generate a sitemap?