예제 #1
0
        public virtual int GetFontSize(ProductTagModel productTag)
        {
            double mean = 0;
            var itemWeights = new List<double>();
            foreach (var tag in Tags)
                itemWeights.Add(tag.ProductCount);
            double stdDev = StdDev(itemWeights, out mean);

            return GetFontSize(productTag.ProductCount, mean, stdDev);
        }
예제 #2
0
 public ActionResult ProductTagsAll()
 {
     var model = new PopularProductTagsModel();
     model.Tags = _productTagService
         .GetAllProductTags()
         //filter by current store
         .Where(x => _productTagService.GetProductCount(x.Id, _storeContext.CurrentStore.Id) > 0)
         //sort by name
         .OrderBy(x => x.GetLocalized(y => y.Name))
         .Select(x =>
                     {
                         var ptModel = new ProductTagModel()
                         {
                             Id = x.Id,
                             Name = x.GetLocalized(y => y.Name),
                             SeName = x.GetSeName(),
                             ProductCount = _productTagService.GetProductCount(x.Id, _storeContext.CurrentStore.Id)
                         };
                         return ptModel;
                     })
         .ToList();
     return View(model);
 }
예제 #3
0
        public ActionResult ProductTags(int productId)
        {
            var product = _productService.GetProductById(productId);
            if (product == null)
                throw new ArgumentException("No product found with the specified id");

            var cacheKey = string.Format(ModelCacheEventConsumer.PRODUCTTAG_BY_PRODUCT_MODEL_KEY, product.Id, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id);
            var cacheModel = _cacheManager.Get(cacheKey, () =>
                {
                    var model = product.ProductTags
                        //filter by store
                        .Where(x => _productTagService.GetProductCount(x.Id, _storeContext.CurrentStore.Id) > 0)
                        .Select(x =>
                                    {
                                        var ptModel = new ProductTagModel()
                                        {
                                            Id = x.Id,
                                            Name = x.GetLocalized(y => y.Name),
                                            SeName = x.GetSeName(),
                                            ProductCount = _productTagService.GetProductCount(x.Id, _storeContext.CurrentStore.Id)
                                        };
                                        return ptModel;
                                    })
                        .ToList();
                    return model;
                });

            return PartialView(cacheModel);
        }