public virtual async Task <IEnumerable <SitemapEntry> > GetEntriesAsync(SitemapParams sitemapParams, CultureInfo culture, int offset, int count) { Guard.NotNull(sitemapParams, nameof(sitemapParams)); Guard.NotNullOrWhiteSpace(sitemapParams.BaseUrl, $"{nameof(sitemapParams)}.{nameof(sitemapParams.BaseUrl)}"); Guard.NotNullOrWhiteSpace(sitemapParams.Scope, $"{nameof(sitemapParams)}.{nameof(sitemapParams.Scope)}"); Guard.NotNull(culture, nameof(culture)); var request = new SearchProductRequest { ScopeId = sitemapParams.Scope, CultureName = culture.Name, Keywords = "*", StartingIndex = offset, MaximumItems = count, VariantGroupingStrategy = SearchVariantGroupingStrategy.PerProduct, }; var response = await _overtureClient.SendAsync(request).ConfigureAwait(false); if (!response.Documents.Any()) { return(Enumerable.Empty <SitemapEntry>()); } return(CreateStandardSitemapEntries(sitemapParams, response.Documents, culture)); }
public IEnumerable <SitemapEntry> GetEntries(SitemapParams sitemapParams, CultureInfo culture) { using (var conn = new DataConnection(culture)) { foreach (var typeFullName in _dataTypesToIncludeFromConfig) { var type = Type.GetType(typeFullName); if (type == null) { Log.LogInformation("Sitemap", $"The configured {type} doesn't exsits"); continue; } var allWebsitePages = new HashSet <Guid>(PageStructureInfo.GetAssociatedPageIds(sitemapParams.Website, SitemapScope.All)); var items = DataFacade.GetData(type).Cast <IPageRelatedData>().Where(d => allWebsitePages.Contains(d.PageId)); foreach (var item in items) { var sitemapEntry = CreateSitemapEntryFromRelatedData(sitemapParams.BaseUrl, item); if (sitemapEntry != null) { yield return(sitemapEntry); } } } } }
public virtual GetProductUrlParam GetProductUrlParams(SitemapParams sitemapParams, CultureInfo culture, PropertyBag propertyBag) { return(new WebsiteGetProductUrlParam { WebsiteId = sitemapParams.Website, CultureInfo = culture, ProductId = (string)propertyBag["ProductId"], ProductName = (string)propertyBag["DisplayName"], SKU = propertyBag.ContainsKey("Sku") ? (string)propertyBag["Sku"] : null, BaseUrl = sitemapParams.BaseUrl }); }
protected virtual IEnumerable <SitemapEntry> CreateStandardSitemapEntries(SitemapParams sitemapParams, List <Document> documents, CultureInfo culture) { foreach (var product in documents) { if (!IsDocumentValid(product.PropertyBag)) { continue; } var productRelativeLocation = _productUrlProvider.GetProductUrl( _productUrlParamFactory.GetProductUrlParams(sitemapParams, culture, product.PropertyBag) ); var productAbsoluteLocation = new Uri(new Uri(sitemapParams.BaseUrl), productRelativeLocation).ToString(); yield return(new SitemapEntry { Location = productAbsoluteLocation, }); } }
public Task <IEnumerable <SitemapEntry> > GetEntriesAsync(SitemapParams sitemapParams, CultureInfo culture, int offset, int count) { // Get the instance of CompositeC1SiteMapProvider configured in the Web.config file //<siteMap defaultProvider="CompositeC1"> // <providers> // <add name="CompositeC1" type="Composite.AspNet.CompositeC1SiteMapProvider, Composite" /> // </providers> //</siteMap> var provider = SiteMap.Provider as CmsPageSiteMapProvider; if (provider == null) { throw new Exception("SiteMap provider is not configured in Web.config to use Composite.AspNet.CompositeC1SiteMapProvider."); } // Because the GetRootNodes -> LoadSiteMap needs a valid HttpCurrent we create it if it is null // by only using specifying the baseUrl in the HttpRequest object // Source: CompositeC1 -> CompositeC1SiteMapProvider.cs (line 276) RequestUtils.DefineHttpContextIfNotExist(sitemapParams.BaseUrl); var entriesList = new List <SitemapEntry>(); var rootNodes = provider.GetRootNodes().ToList(); // Get root node associated to culture and website var rootNode = rootNodes.FirstOrDefault(node => node.Culture.Equals(culture) && node.Page?.Id == sitemapParams.Website); var pageIdsToExclude = _pageToExcludeProvider.GetPageIdsToExclude(sitemapParams.Website, culture); var allNodes = rootNode?.GetAllNodes() .OfType <CmsPageSiteMapNode>() .Where(node => node.Page == null || !pageIdsToExclude.Contains(node.Page.Id)) .Select(node => CreateSitemapEntryFromCompositeC1SiteMapNode(sitemapParams.BaseUrl, node)); entriesList.AddRange(allNodes); var dynamicTypesToInclude = _dynamicPagesEntryProvider.GetEntries(sitemapParams, culture); entriesList.AddRange(dynamicTypesToInclude); return(Task.FromResult(entriesList as IEnumerable <SitemapEntry>)); }
public virtual async Task <IEnumerable <SitemapEntry> > GetEntriesAsync(SitemapParams param, CultureInfo culture, int offset, int count) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (string.IsNullOrWhiteSpace(param.BaseUrl)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.BaseUrl)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } if (culture == null) { throw new ArgumentNullException(nameof(culture)); } var request = new SearchProductRequest { ScopeId = param.Scope, CultureName = culture.Name, Keywords = "*", StartingIndex = offset, MaximumItems = count, VariantGroupingStrategy = SearchVariantGroupingStrategy.PerProduct, }; var response = await _overtureClient.SendAsync(request).ConfigureAwait(false); if (!response.Documents.Any()) { return(Enumerable.Empty <SitemapEntry>()); } return(CreateStandardSitemapEntries(param, response.Documents, culture)); }