Skip to content

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.

RelatedProducts - remove cache

KrzysztofPajakf44a43bc3bc8
diff --git a/src/Web/Grand.Web/Components/RelatedProducts.cs b/src/Web/Grand.Web/Components/RelatedProducts.cs
index 0b442fdb0..bd8c4f582 100644
--- a/src/Web/Grand.Web/Components/RelatedProducts.cs
+++ b/src/Web/Grand.Web/Components/RelatedProducts.cs
@@ -1,10 +1,7 @@
using Grand.Business.Catalog.Interfaces.Products;
-using Grand.Infrastructure;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Catalog;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
-using Grand.Web.Events.Cache;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
@@ -15,9 +12,7 @@ namespace Grand.Web.Components
public class RelatedProductsViewComponent : BaseViewComponent
{
#region Fields
- private readonly ICacheBase _cacheBase;
private readonly IProductService _productService;
- private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
private readonly CatalogSettings _catalogSettings;
@@ -26,15 +21,11 @@ namespace Grand.Web.Components
#region Constructors
public RelatedProductsViewComponent(
- ICacheBase cacheBase,
IProductService productService,
- IWorkContext workContext,
IMediator mediator,
CatalogSettings catalogSettings)
{
- _cacheBase = cacheBase;
_productService = productService;
- _workContext = workContext;
_mediator = mediator;
_catalogSettings = catalogSettings;
}
@@ -45,14 +36,12 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(string productId, int? productThumbPictureSize)
{
- var productIds = await _cacheBase.GetAsync(string.Format(CacheKeyConst.PRODUCTS_RELATED_IDS_KEY, productId, _workContext.CurrentStore.Id),
- async () => (await _productService.GetProductById(productId)).RelatedProducts.OrderBy(x => x.DisplayOrder).Select(x => x.ProductId2).ToArray());
+ var productIds = (await _productService.GetProductById(productId)).RelatedProducts.OrderBy(x => x.DisplayOrder).Select(x => x.ProductId2).ToArray();
//load products
var products = await _productService.GetProductsByIds(productIds);
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview() {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs b/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
index dd6855ea3..baf398c58 100644
--- a/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
+++ b/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
@@ -267,15 +267,6 @@ namespace Grand.Web.Events.Cache
/// </remarks>
public const string PRODUCTS_ALSO_PURCHASED_IDS_KEY = "Grand.product.id-{0}-{1}.press.alsopurchased";
- /// <summary>
- /// Key for "related" product identifiers displayed on the product details page
- /// </summary>
- /// <remarks>
- /// {0} : current product id
- /// {1} : current store ID
- /// </remarks>
- public const string PRODUCTS_RELATED_IDS_KEY = "Grand.product.id-{0}-{1}.pres.related";
-
/// <summary>
/// Key for blog tag list model
/// </summary>