Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
ProductTagService - remove unused parameter (storeId)
support9ea899ca6d04
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.csindex 9064f280d..7fb883fea 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs@@ -50,12 +50,10 @@ namespace Grand.Business.Catalog.Services.Products/// <summary>/// Get product count for each of existing product tag/// </summary>- /// <param name="storeId">Store identifier</param>/// <returns>Dictionary of "product tag ID : product count"</returns>- private async Task<Dictionary<string, int>> GetProductCount(string storeId)+ private async Task<Dictionary<string, int>> GetProductCount(){- var key = string.Format(CacheKey.PRODUCTTAG_COUNT_KEY, storeId);- return await _cacheBase.GetAsync(key, async () =>+ return await _cacheBase.GetAsync(CacheKey.PRODUCTTAG_COUNT_KEY, async () =>{var query = from pt in _productTagRepository.Tableselect pt;@@ -232,12 +230,11 @@ namespace Grand.Business.Catalog.Services.Products/// Get number of products/// </summary>/// <param name="productTagId">Product tag identifier</param>- /// <param name="storeId">Store identifier</param>/// <returns>Number of products</returns>- public virtual async Task<int> GetProductCount(string productTagId, string storeId)+ public virtual async Task<int> GetProductCount(string productTagId){- var dictionary = await GetProductCount(storeId);- return dictionary.ContainsKey(productTagId) ? dictionary[productTagId] : 0;+ var dictionary = await GetProductCount();+ return dictionary.TryGetValue(productTagId, out var value) ? value : 0;}#endregiondiff --git a/src/Business/Grand.Business.Core/Interfaces/Catalog/Products/IProductTagService.cs b/src/Business/Grand.Business.Core/Interfaces/Catalog/Products/IProductTagService.csindex ef64d89e5..9713f775b 100644--- a/src/Business/Grand.Business.Core/Interfaces/Catalog/Products/IProductTagService.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Catalog/Products/IProductTagService.cs@@ -71,8 +71,7 @@ namespace Grand.Business.Core.Interfaces.Catalog.Products/// Get number of products/// </summary>/// <param name="productTagId">Product tag identifier</param>- /// <param name="storeId">Store identifier</param>/// <returns>Number of products</returns>- Task<int> GetProductCount(string productTagId, string storeId);+ Task<int> GetProductCount(string productTagId);}}diff --git a/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs b/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.csindex 81e323d98..6ea21811d 100644--- a/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs+++ b/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs@@ -89,7 +89,7 @@/// <remarks>/// {0} : store ID/// </remarks>- public static string PRODUCTTAG_COUNT_KEY => "Grand.producttag.count-{0}";+ public static string PRODUCTTAG_COUNT_KEY => "Grand.producttag.count";/// <summary>/// Key for all tagsdiff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.csindex e41c6479f..773daacb9 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs@@ -197,7 +197,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products};await _productTagService.InsertProductTag(productTag);//Act- var result = await _productTagService.GetProductCount(productTag.Id, "");+ var result = await _productTagService.GetProductCount(productTag.Id);//AssertAssert.AreEqual(10, result);diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductTagsController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductTagsController.csindex 7f85f6cbb..69481f2af 100644--- a/src/Web/Grand.Web.Admin/Controllers/ProductTagsController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ProductTagsController.cs@@ -55,7 +55,7 @@ namespace Grand.Web.Admin.Controllersvar ptag = new ProductTagModel {Id = item.Id,Name = item.Name,- ProductCount = await _productTagService.GetProductCount(item.Id, "")+ ProductCount = await _productTagService.GetProductCount(item.Id)};productTags.Add(ptag);}@@ -101,7 +101,7 @@ namespace Grand.Web.Admin.Controllers{Id = productTag.Id,Name = productTag.Name,- ProductCount = await _productTagService.GetProductCount(productTag.Id, "")+ ProductCount = await _productTagService.GetProductCount(productTag.Id)};//localesawait AddLocales(_languageService, model.Locales, (locale, languageId) =>diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.csindex bd21a3160..12705dfc3 100644--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs@@ -18,22 +18,20 @@ namespace Grand.Web.Features.Handlers.Catalogpublic async Task<PopularProductTagsModel> Handle(GetProductTagsAll request, CancellationToken cancellationToken){var model = new PopularProductTagsModel();- var tagsTask = (await _productTagService+ model.Tags = (await _productTagService.GetAllProductTags()).OrderBy(x => x.Name)- .Select(async x =>+ .Select(x =>{var ptModel = new ProductTagModel{Id = x.Id,Name = x.GetTranslation(y => y.Name, request.Language.Id),SeName = x.SeName,- ProductCount = await _productTagService.GetProductCount(x.Id, request.Store.Id)+ ProductCount = x.Count};return ptModel;- });-- model.Tags = await Task.WhenAll(tagsTask);+ }).ToList();return model;}}diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.csindex 8757aa309..eaa5d5c4c 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs@@ -577,8 +577,7 @@ namespace Grand.Web.Features.Handlers.ProductsId = tag.Id,Name = tag.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id),SeName = tag.SeName,- ProductCount =- await _productTagService.GetProductCount(tag.Id, _workContext.CurrentStore.Id)+ ProductCount = tag.Count});}}