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
KrzysztofPajakf9e275072de8
diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.csindex 364b30ebc..e07ce5d84 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs@@ -1,10 +1,10 @@using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Catalog.Queries.Models;-using Grand.Infrastructure.Caching;-using Grand.Infrastructure.Caching.Constants;using Grand.Domain.Catalog;using Grand.Domain.Customers;using Grand.Domain.Data;+using Grand.Infrastructure.Caching;+using Grand.Infrastructure.Caching.Constants;using MediatR;using System.Collections.Generic;using System.Linq;@@ -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..51f42c51d 100644--- a/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Models/GetRecommendedProductsQuery.cs@@ -7,5 +7,6 @@ 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..3d9355cbd 100644--- a/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs+++ b/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs@@ -43,7 +43,7 @@ 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("");