示例#1
0
        private bool ExistsAlready(CategoryFacetManager manager, string categoryBvin, long propertyId)
        {
            var facets = manager.FindByCategory(categoryBvin);

            if (facets != null)
            {
                var count = facets.Where(y => y.PropertyId == propertyId).Count();
                if (count > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        /* Filters Area */

        private void RenderFilterTree()
        {
            StringBuilder sb = new StringBuilder();

            CategoryFacetManager manager = CategoryFacetManager.InstantiateForDatabase(MTApp.CurrentRequestContext);

            List <CategoryFacet> allFacets = manager.FindByCategory(this.BvinField.Value);

            this.lstParents.Items.Clear();
            this.lstParents.Items.Add(new System.Web.UI.WebControls.ListItem("Nothing (always show)", "0"));
            this.lstParents.Items.Add(new System.Web.UI.WebControls.ListItem("", "0"));
            foreach (CategoryFacet f in allFacets)
            {
                this.lstParents.Items.Add(new System.Web.UI.WebControls.ListItem(f.FilterName, f.Id.ToString()));
            }
            RenderChildren(0, allFacets, sb, manager);

            this.litMain.Text = sb.ToString();
        }
 private bool ExistsAlready(CategoryFacetManager manager, string categoryBvin, long propertyId)
 {
     var facets = manager.FindByCategory(categoryBvin);
     if (facets != null)
     {
         var count = facets.Where(y => y.PropertyId == propertyId).Count();
         if (count > 0)
         {
             return true;
         }
     }
     return false;
 }
        public ActionResult DrillDownIndex(string slug)
        {
            ViewBag.BodyClass = "store-categorydrilldown-page";

            Category cat = MTApp.CatalogServices.Categories.FindBySlugForStore(slug,
                                                                               MTApp.CurrentRequestContext.CurrentStore.Id);

            if (cat == null)
            {
                cat = new Category();
            }

            ViewBag.Title = cat.MetaTitle;
            if (String.IsNullOrEmpty(ViewBag.Title))
            {
                ViewBag.Title = cat.Name;
            }
            ViewBag.MetaKeywords    = cat.MetaKeywords;
            ViewBag.MetaDescription = cat.MetaDescription;
            ViewBag.DisplayHtml     = TagReplacer.ReplaceContentTags(cat.Description,
                                                                     this.MTApp,
                                                                     "",
                                                                     Request.IsSecureConnection);

            string key = Request.QueryString["node"] ?? string.Empty;

            if (key == "-")
            {
                key = string.Empty;
            }
            ViewBag.Key = key;

            int pageNumber = GetPageNumber();
            int pageSize   = 9;
            int totalItems = 0;



            CategoryPageViewModel model = new CategoryPageViewModel();


            CategoryFacetManager   manager    = CategoryFacetManager.InstantiateForDatabase(MTApp.CurrentRequestContext);
            List <CategoryFacet>   facets     = manager.FindByCategory(cat.Bvin);
            List <ProductProperty> properties = LoadProperties(facets);

            if (key == string.Empty)
            {
                key = CategoryFacetKeyHelper.BuildEmptyKey(facets.Count);
            }
            List <long> parsedKey = CategoryFacetKeyHelper.ParseKeyToList(key);

            List <Product> products = MTApp.CatalogServices.FindProductsMatchingKey(key,
                                                                                    pageNumber,
                                                                                    pageSize,
                                                                                    ref totalItems);

            List <ProductFacetCount> productCounts = manager.FindCountsOfVisibleFacets(key, facets, properties);
            List <long> visibleIds = manager.FindVisibleFacetsIdsForKey(key, facets);

            model.Products                 = PrepProducts(products);
            model.LocalCategory            = cat;
            model.PagerData.PageSize       = pageSize;
            model.PagerData.TotalItems     = totalItems;
            model.PagerData.CurrentPage    = pageNumber;
            model.PagerData.PagerUrlFormat = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                                                             MTApp.CurrentRequestContext.RoutingContext,
                                                                             "{0}");
            model.PagerData.PagerUrlFormatFirst = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                                                                  MTApp.CurrentRequestContext.RoutingContext);
            model.SubCategories = PrepSubCategories(MTApp.CatalogServices.Categories.FindVisibleChildren(cat.Bvin));



            StringBuilder sbNotSelected = new StringBuilder();

            List <BreadCrumbItem> extraCrumbs = new List <BreadCrumbItem>();

            for (int i = 0; i < facets.Count; i++)
            {
                if (visibleIds.Contains(facets[i].Id))
                {
                    // Find the property that matches the facet
                    var p = (from pr in properties
                             where pr.Id == facets[i].PropertyId
                             select pr).SingleOrDefault();
                    if (p != null)
                    {
                        if (parsedKey[i] < 1)
                        {
                            // not selected
                            this.RenderNonSelection(sbNotSelected, i, parsedKey[i], key, facets[i], p, productCounts, model);
                        }
                        else
                        {
                            // selected
                            this.RenderSelection(sbNotSelected, i, parsedKey[i], key, facets[i], p, facets, model, extraCrumbs);
                        }
                    }
                }
            }

            ViewBag.ExtraCrumbs = extraCrumbs;
            ViewBag.Filters     = sbNotSelected.ToString();



            // Banner
            if (cat.BannerImageUrl.Trim().Length > 0)
            {
                ViewBag.ShowBanner = true;
                ViewBag.BannerUrl  = MerchantTribe.Commerce.Storage.DiskStorage.CategoryBannerUrl(
                    MTApp,
                    cat.Bvin,
                    cat.BannerImageUrl,
                    Request.IsSecureConnection);
            }
            else
            {
                ViewBag.ShowBanner = false;
            }

            // Record Category View
            MerchantTribe.Commerce.SessionManager.CategoryLastId = cat.Bvin;

            return(View("DrillDown", model));
        }