How can I include all (published) variant page URLs in the sitemap that Litium generates?
I’ve tried setting the includeProducts attribute to true on the sitemap element in web.config but doesn’t seem to make any difference.
Litium version: 6.2.2
How can I include all (published) variant page URLs in the sitemap that Litium generates?
I’ve tried setting the includeProducts attribute to true on the sitemap element in web.config but doesn’t seem to make any difference.
Litium version: 6.2.2
See for example https://www.teknikmagasinet.se/sitemap.axd?page=1 which contains product page URLs.
@anusha.ganegoda @patric.forsgard I think I might have found a bug in SitemapFactory.cs, in AddProductRecursively. In the first foreach loop, shouldn’t
else if (this._keyLookupService.TryGetId<BaseProduct>(result1, out id))
in fact be
else if (this._keyLookupService.TryGetId<Variant>(result1, out id))
?
protected virtual void AddProductRecursively(List<SitemapItem> result, Category category, Page page, bool showProductGroupRecurslively)
{
if (category == null || !CmsConfig.Instance.IncludeProductsInSiteMap)
return;
int pageNumber = 1;
while (true)
{
QueryRequest queryRequest1 = new QueryRequest(page.WebSite.Language.ID, ProductCatalogSearchDomains.Products, Solution.Instance.AnonymousToken);
queryRequest1.Paging = new Paging(pageNumber, 100000);
QueryRequest queryRequest2 = queryRequest1;
queryRequest2.FilterTags.Add((ITag) new Tag(showProductGroupRecurslively ? TagNames.GetTagNameForCategoryTree(page.WebSiteID) : "CategorySystemId", category.SystemId)
{
Analyzer = "whitespace"
});
queryRequest2.FilterTags.Add((ITag) new Tag("ActiveWebSiteSystemId", page.WebSiteID)
{
Analyzer = "whitespace"
});
SearchResponse searchResponse = Solution.Instance.SearchService.Search(queryRequest2);
if (searchResponse.Hits.Count != 0)
{
List<Guid> guidList1 = new List<Guid>();
List<Guid> guidList2 = new List<Guid>();
foreach (Hit hit in searchResponse.Hits)
{
Guid result1;
if (Guid.TryParse(hit.Id, out result1))
{
string id;
if (this._keyLookupService.TryGetId<BaseProduct>(result1, out id))
guidList1.Add(result1);
else if (this._keyLookupService.TryGetId<BaseProduct>(result1, out id))
guidList2.Add(result1);
}
}
Dictionary<Guid, AuditSummary> dictionary1 = this._auditService.GetSummary<BaseProduct>((IEnumerable<Guid>) guidList1).ToDictionary<AuditSummary, Guid>((Func<AuditSummary, Guid>) (x => x.SystemId));
foreach (BaseProduct baseProduct in this._baseProductService.Get((IEnumerable<Guid>) guidList1))
{
AuditSummary auditSummary;
this.AddItem(result, baseProduct, page, dictionary1.TryGetValue(baseProduct.SystemId, out auditSummary) ? auditSummary : (AuditSummary) null);
}
Dictionary<Guid, AuditSummary> dictionary2 = this._auditService.GetSummary<Litium.Products.Variant>((IEnumerable<Guid>) guidList2).ToDictionary<AuditSummary, Guid>((Func<AuditSummary, Guid>) (x => x.SystemId));
foreach (Litium.Products.Variant variant in this._variantService.Get((IEnumerable<Guid>) guidList2))
{
AuditSummary auditSummary;
this.AddItem(result, variant, page, dictionary2.TryGetValue(variant.SystemId, out auditSummary) ? auditSummary : (AuditSummary) null);
}
++pageNumber;
}
else
break;
}
}
yeah looks like a bug, please file a bug