Exemple #1
0
        public ActionResult Products()
        {
            var sitemapItems = new List <SitemapItem>();

            String key = String.Format("ProductSitemapItemCache-{0}", StoreId);

            ProductSitemapItemCache.TryGet(key, out sitemapItems);

            if (sitemapItems == null)
            {
                sitemapItems = new List <SitemapItem>();
                var products   = ProductRepository.GetProductByTypeAndCategoryIdFromCache(StoreId, StoreConstants.ProductType, -1);
                var categories = ProductCategoryService.GetProductCategoriesByStoreIdFromCache(StoreId,
                                                                                               StoreConstants.ProductType);
                foreach (var product in products)
                {
                    var cat = categories.FirstOrDefault(r => r.Id == product.ProductCategoryId);
                    if (cat != null)
                    {
                        var productDetailLink = LinkHelper.GetProductIdRouteValue(product, cat.Name);
                        var siteMap           = new SitemapItem(Url.AbsoluteAction("Product", "Products", new { id = productDetailLink }),
                                                                changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0);
                        sitemapItems.Add(siteMap);
                    }
                }
                ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds));
            }
            return(new SitemapResult(sitemapItems));
        }
        public ActionResult GetProductCategories()
        {
            var    categories      = ProductCategoryService.GetProductCategoriesByStoreIdFromCache(MyStore.Id, StoreConstants.ProductType);
            String partialViewName = @"pProducts\pProductCategories";
            var    html            = this.RenderPartialToString(partialViewName, new ViewDataDictionary(categories));

            return(Json(html, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult ProductCategories()
        {
            var sitemapItems = new List <SitemapItem>();

            String key = String.Format("ProductCategoriesSiteMap-{0}", StoreId);

            ProductSitemapItemCache.TryGet(key, out sitemapItems);

            if (sitemapItems == null)
            {
                sitemapItems = new List <SitemapItem>();
                var categories = ProductCategoryService.GetProductCategoriesByStoreIdFromCache(StoreId,
                                                                                               StoreConstants.ProductType);
                foreach (var category in categories)
                {
                    var productDetailLink = LinkHelper.GetProductCategoryIdRouteValue(category);
                    var siteMap           = new SitemapItem(Url.AbsoluteAction("category", "productcategories", new { id = productDetailLink }),
                                                            changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0);
                    sitemapItems.Add(siteMap);
                }
                ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds));
            }
            return(new SitemapResult(sitemapItems));
        }