/// <summary> /// This method returns the dynamicly generated URL based on the item type. /// </summary> /// <param name="item">The item</param> /// <param name="options">The options</param> /// <returns>The dynamically built URL</returns> public override string GetDynamicUrl(Item item, LinkUrlOptions options) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(options, "options"); var url = string.Empty; var itemType = item.ItemType(); bool productCatalogLinkRequired = Sitecore.Web.WebUtil.GetRawUrl().IndexOf(ProductItemResolver.NavigationItemName, System.StringComparison.OrdinalIgnoreCase) >= 0; if (productCatalogLinkRequired) { url = CatalogUrlManager.BuildProductCatalogLink(item); } else if (this.UseShopLinks) { if (itemType == StorefrontConstants.ItemTypes.Product) { url = CatalogUrlManager.BuildProductShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName, true); } else if (itemType == StorefrontConstants.ItemTypes.Category) { url = CatalogUrlManager.BuildCategoryShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } else if (itemType == StorefrontConstants.ItemTypes.Variant) { url = CatalogUrlManager.BuildVariantShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName, true); } } else { if (itemType == StorefrontConstants.ItemTypes.Product) { url = CatalogUrlManager.BuildProductLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } else if (itemType == StorefrontConstants.ItemTypes.Category) { url = CatalogUrlManager.BuildCategoryLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } } if (string.IsNullOrEmpty(url)) { url = base.GetDynamicUrl(item, options); } return(url); }
/// <summary> /// This method returns the dynamicly generated URL based on the item type. /// </summary> /// <param name="item">The item</param> /// <param name="options">The options</param> /// <returns>The dynamically built URL</returns> public override string GetDynamicUrl(Item item, LinkUrlOptions options) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(options, "options"); var url = string.Empty; var searchManager = CommerceTypeLoader.CreateInstance <ICommerceSearchManager>(); if (this.UseShopLinks) { if (searchManager.IsItemProduct(item)) { url = CatalogUrlManager.BuildProductShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName, true); } else if (searchManager.IsItemCategory(item)) { url = CatalogUrlManager.BuildCategoryShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } else if (this.UseShopLinks && searchManager.IsItemVariant(item)) { url = CatalogUrlManager.BuildVariantShopLink(item, this.IncludeCatalog, this.IncludeFriendlyName, true); } } else { if (searchManager.IsItemProduct(item)) { url = CatalogUrlManager.BuildProductLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } else if (searchManager.IsItemCategory(item)) { url = CatalogUrlManager.BuildCategoryLink(item, this.IncludeCatalog, this.IncludeFriendlyName); } } if (string.IsNullOrEmpty(url)) { url = base.GetDynamicUrl(item, options); } return(url); }