Asp.net mvc 4 NopCommerce:在分类主页上显示畅销产品
我正在使用NopCommerce。我想在分类主页上显示前三名的畅销书产品 我的想法是,在视图端Asp.net mvc 4 NopCommerce:在分类主页上显示畅销产品,asp.net-mvc-4,nopcommerce,Asp.net Mvc 4,Nopcommerce,我正在使用NopCommerce。我想在分类主页上显示前三名的畅销书产品 我的想法是,在视图端CategoryTemplate.ProductsInGridOrLines.cshtml和控制器端CatalogController.cs>HomepageBestSellers使用方法。 我已将类别id作为参数传递给HomepageBestSellers方法。此类别id作为参数传递给BestSellersReport方法 我的问题是如何使用category id在category主页上显示畅销产品
CategoryTemplate.ProductsInGridOrLines.cshtml
和控制器端CatalogController.cs>HomepageBestSellers
使用方法。我已将类别id作为参数传递给HomepageBestSellers方法。此类别id作为参数传递给BestSellersReport方法 我的问题是如何使用category id在category主页上显示畅销产品
_orderReportService.BestSellersReport(storeId:_storeContext.CurrentStore.Id,categoryId:categoryId)
非电子商务中的畅销产品代码
#region bestsellers and products
[ChildActionOnly]
public ActionResult BestSellProduct(int categoryId)
{
//load and cache report
var report = _orderReportService.BestSellersReport(storeId: _storeContext.CurrentStore.Id, categoryId: categoryId);
//load products
var products = _productService.GetProductsByIds(report.Select(x => x.ProductId).ToArray());
//ACL and store mapping
products = products.Where(p => _aclService.Authorize(p) && _storeMappingService.Authorize(p)).ToList();
//availability dates
products = products.Where(p => p.IsAvailable()).ToList();
if (!products.Any())
return Content("");
//prepare model
var model = PrepareProductOverviewModels(products, true, true, categoryId).ToList();
return PartialView(model);
}
#endregion
您能告诉我如何使用查询将类别表与订单表连接起来吗?为什么要这样做?我只想显示该特定类别的畅销产品。请按照我编写的说明进行操作。不再需要做任何事情。查看HomepageBestSellers方法-您的代码应该与之非常相似。_orderReportService.BestSellersReport(storeId:_storeContext.CurrentStore.Id,categoryId:categoryId)。此处的categoryId表示仅针对具有此id的类别显示产品。