kniganapolke / NopCommerce.Recommendations.SimilarProductsPlugin

MIT License
4 stars 3 forks source link

Recommendations include unpublished products #3

Open kniganapolke opened 2 years ago

kniganapolke commented 2 years ago

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.

ciussky commented 1 year 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