Open kniganapolke opened 2 years ago
I changed the code like this
//load products
var products = await (await _productService.GetProductsByIdsAsync(productIds))
//ACL and store mapping
.WhereAwait(async p => await _aclService.AuthorizeAsync(p) && await _storeMappingService.AuthorizeAsync(p))
//published
.Where(p => p.Published)
//availability dates
.Where(p => _productService.ProductIsAvailable(p))
//visible individually
.Where(p => p.VisibleIndividually)
.Take(settings.NumOfSimilarProductsToDisplay)
.ToListAsync();
added the //published .Where(p => p.Published) to load published products only, it looks like it works
in components/SimilarProductsViewComponent.cs
There is a setting catalogsettings.allowviewunpublishedproductpage that should be taken into account when loading products. If it's set to False, unpublished products should not be loaded.