コード例 #1
0
        private string GetCategoryUrl(Ucommerce.EntitiesV2.Category category)
        {
            var baseUrl = string.Empty;

            if (this.categoryPageId == Guid.Empty)
            {
                baseUrl = UrlResolver.GetCurrentPageNodeUrl();
            }
            else
            {
                baseUrl = UrlResolver.GetPageNodeUrl(this.categoryPageId);
            }

            var    searchCategory = CatalogLibrary.GetCategory(category.Guid);
            var    catUrl         = GetCategoryPath(searchCategory);
            string relativeUrl    = string.Concat(VirtualPathUtility.RemoveTrailingSlash(baseUrl), "/", catUrl);
            string url;

            if (SystemManager.CurrentHttpContext.Request.Url != null)
            {
                url = UrlPath.ResolveUrl(relativeUrl, true);
            }
            else
            {
                url = UrlResolver.GetAbsoluteUrl(SiteMapBase.GetActualCurrentNode().Url);
            }

            return(url);
        }
コード例 #2
0
        private IList <FacetViewModel> GetAllFacets(Ucommerce.EntitiesV2.Category category)
        {
            var facets = HttpContext.Current.Request.QueryString.ToFacets();
            IList <Ucommerce.Search.Facets.Facet> allFacets;

            if (category != null)
            {
                allFacets = CatalogLibrary.GetFacets(category.Guid, facets.ToFacetDictionary());
            }
            else
            {
                allFacets = CatalogLibrary.GetFacets(CatalogContext.CurrentCatalog.Categories, facets.ToFacetDictionary());
            }

            return(this.MapToFacetsViewModel(allFacets));
        }
コード例 #3
0
        protected virtual IList <CategoryNavigationCategoryViewModel> MapCategories(ICollection <Ucommerce.EntitiesV2.Category> rootCategories,
                                                                                    Ucommerce.EntitiesV2.Category currentCategory)
        {
            var result = new List <CategoryNavigationCategoryViewModel>();

            foreach (var category in rootCategories)
            {
                result.Add(new CategoryNavigationCategoryViewModel()
                {
                    CategoryId  = category.CategoryId,
                    DisplayName = category.DisplayName(),
                    Url         = this.GetCategoryUrl(category),
                    Categories  = this.MapCategories(category.Categories.Where(x => x.DisplayOnSite).ToList(),
                                                     currentCategory),
                    IsActive = currentCategory != null && currentCategory.Guid == category.Guid,
                });
            }

            return(result);
        }
コード例 #4
0
        // TODO: Check if we're manually sorting the products (as we do on the product listing page)
        public virtual IList <FacetViewModel> CreateViewModel()
        {
            Ucommerce.EntitiesV2.Category currentCategory = null;

            if (CatalogContext.CurrentCategory != null)
            {
                currentCategory = Ucommerce.EntitiesV2.Category.FirstOrDefault(c => c.Name == CatalogContext.CurrentCategory.Name);
                return(this.GetAllFacets(currentCategory));
            }

            var pageContext = SystemManager.CurrentHttpContext.GetProductsContext();
            var categoryIds = pageContext.GetValue <ProductsController>(p => p.CategoryIds);
            var productIds  = pageContext.GetValue <ProductsController>(p => p.ProductIds);

            if (!string.IsNullOrEmpty(categoryIds) || !string.IsNullOrEmpty(productIds))
            {
                return(this.MapFacetsByManualSelection(categoryIds, productIds));
            }

            return(this.GetAllFacets(currentCategory));
        }