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
Allow to use recommended products per store
KrzysztofPajake794e7e135b4
diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.csindex 364b30ebc..a875dcbdc 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs@@ -32,7 +32,7 @@ namespace Grand.Business.Catalog.Queries.Handlerspublic async Task<IList<Product>> Handle(GetRecommendedProductsQuery request, CancellationToken cancellationToken){- return await _cacheBase.GetAsync(string.Format(CacheKey.PRODUCTS_CUSTOMER_GROUP, string.Join(",", request.CustomerGroupIds)), async () =>+ return await _cacheBase.GetAsync(string.Format(CacheKey.PRODUCTS_CUSTOMER_GROUP, string.Join(",", request.CustomerGroupIds), request.StoreId), async () =>{var query = from cr in _customerGroupProductRepository.Tablewhere request.CustomerGroupIds.Contains(cr.CustomerGroupId)diff --git a/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.cs b/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.csindex dbfe1bda1..f44154c13 100644--- a/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.cs@@ -7,5 +7,7 @@ namespace Grand.Business.Catalog.Queries.Modelspublic class GetRecommendedProductsQuery : IRequest<IList<Product>>{public string[] CustomerGroupIds { get; set; }++ public string StoreId { get; set; }}}diff --git a/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs b/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.csindex 998ed0dc6..a388154dd 100644--- a/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs+++ b/src/Core/Grand.Infrastructure/Caching/Constants/ProductCacheKey.cs@@ -20,8 +20,9 @@/// </summary>/// <remarks>/// {0} : customer group IDs+ /// {1} : store ident/// </remarks>- public static string PRODUCTS_CUSTOMER_GROUP => "Grand.product.cr-{0}";+ public static string PRODUCTS_CUSTOMER_GROUP => "Grand.product.cr-{0}-{1}";/// <summary>/// Key for cachingdiff --git a/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs b/src/Web/Grand.Web/Components/CustomerRecommendedProducts.csindex 3edcfcb40..a17b76e43 100644--- a/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs+++ b/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs@@ -43,7 +43,8 @@ namespace Grand.Web.Componentsif (!_catalogSettings.RecommendedProductsEnabled)return Content("");- var products = await _mediator.Send(new GetRecommendedProductsQuery() { CustomerGroupIds = _workContext.CurrentCustomer.GetCustomerGroupIds() });+ var products = await _mediator.Send(new GetRecommendedProductsQuery() { CustomerGroupIds = _workContext.CurrentCustomer.GetCustomerGroupIds(),+ StoreId = _workContext.CurrentStore.Id });if (!products.Any())return Content("");