Reputation: 1177
Before adding an image to the product variant section the image that was shown for the product in the shopping cart was the first product image in the list of product images for that product. Now the Productvariant image is showing.
How do I keep the productvariant image but revert back to using the first image in the product images as the image that shows in the shopping cart?
@if (Model.ShowProductImages)
{
<td class="productpicture">
<img style="border-width: 0px;" alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
</td>
}
Upvotes: 1
Views: 214
Reputation: 2647
In Nop.Web.Controllers.ShoppingCartController.cs, function 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),
};
}
}
Just change the beginning part of that to:
var picture = _pictureService.GetPicturesByProductId(sci.ProductVariant.Product.Id, 1).FirstOrDefault();
Upvotes: 2