在 Nop.Web.Controllers.ShoppingCartController.cs 中,函数 PrepareShoppingCartModel:
using (profiler.Step("Picture"))
{
//picture
if (_shoppingCartSettings.ShowProductImagesOnShoppingCart)
{
var picture = _pictureService.GetPictureById(sci.ProductVariant.PictureId);
if (picture == null)
{
picture = _pictureService.GetPicturesByProductId(sci.ProductVariant.Product.Id, 1).FirstOrDefault();
}
cartItemModel.Picture = new PictureModel()
{
ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSetting.CartThumbPictureSize, true),
Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), cartItemModel.ProductName),
AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), cartItemModel.ProductName),
};
}
}
只需将其开头部分更改为:
var picture = _pictureService.GetPicturesByProductId(sci.ProductVariant.Product.Id, 1).FirstOrDefault();