@@ -1388,7 +1388,7 @@ protected ProductDetailsModel PrepareProductDetailModel(ProductDetailsModel mode
13881388
13891389 #region Attribute combinations
13901390
1391- if ( ! isBundle || ( isBundle && product . BundlePerItemPricing ) )
1391+ if ( ! isBundle )
13921392 {
13931393 model . Combinations = _productAttributeService . GetAllProductVariantAttributeCombinations ( product . Id ) ;
13941394
@@ -2675,6 +2675,7 @@ public ActionResult UpdateProductDetails(int productId, string itemType, int bun
26752675 int quantity = 1 ;
26762676 int galleryStartIndex = - 1 ;
26772677 string galleryHtml = null ;
2678+ string dynamicThumbUrl = null ;
26782679 bool isAssociated = itemType . IsCaseInsensitiveEqual ( "associateditem" ) ;
26792680 var pictureModel = new ProductDetailsPictureModel ( ) ;
26802681 var m = new ProductDetailsModel ( ) ;
@@ -2702,40 +2703,43 @@ public ActionResult UpdateProductDetails(int productId, string itemType, int bun
27022703 // get merged model data
27032704 PrepareProductDetailModel ( m , product , isAssociated , bundleItem , bundleItems , form , quantity ) ;
27042705
2705- // get updated image gallery
2706- if ( product . ProductType != ProductType . BundledProduct && bundleItem == null )
2707- {
2708- var pictures = _pictureService . GetPicturesByProductId ( productId ) ;
2706+ if ( bundleItem != null ) // update bundle item thumbnail
2707+ {
2708+ if ( ! bundleItem . HideThumbnail )
2709+ {
2710+ var picture = m . GetAssignedPicture ( _pictureService , null , bundleItem . ProductId ) ;
2711+ dynamicThumbUrl = _pictureService . GetPictureUrl ( picture , _mediaSettings . BundledProductPictureSize , false ) ;
2712+ }
2713+ }
2714+ else if ( isAssociated ) // update associated product thumbnail
2715+ {
2716+ var picture = m . GetAssignedPicture ( _pictureService , null , productId ) ;
2717+ dynamicThumbUrl = _pictureService . GetPictureUrl ( picture , _mediaSettings . AssociatedProductPictureSize , false ) ;
2718+ }
2719+ else if ( product . ProductType != ProductType . BundledProduct ) // update image gallery
2720+ {
2721+ var pictures = _pictureService . GetPicturesByProductId ( productId ) ;
27092722
2710- if ( pictures . Count <= _catalogSettings . DisplayAllImagesNumber )
2711- {
2712- // all pictures rendered... only index is required
2713- if ( m . CombinationSelected != null )
2714- {
2715- var combiAssignedImages = m . CombinationSelected . GetAssignedPictureIds ( ) ;
2716- if ( combiAssignedImages . Length > 0 )
2717- {
2718- var picture = pictures . FirstOrDefault ( p => p . Id == combiAssignedImages [ 0 ] ) ;
2719- if ( picture != null )
2720- galleryStartIndex = pictures . IndexOf ( picture ) ;
2721- }
2722- }
2723- }
2724- else
2725- {
2726- var allCombinationImageIds = new List < int > ( ) ;
2723+ if ( pictures . Count <= _catalogSettings . DisplayAllImagesNumber ) // all pictures rendered... only index is required
2724+ {
2725+ var picture = m . GetAssignedPicture ( _pictureService , pictures ) ;
2726+ galleryStartIndex = ( picture == null ? 0 : pictures . IndexOf ( picture ) ) ;
2727+ }
2728+ else
2729+ {
2730+ var allCombinationImageIds = new List < int > ( ) ;
27272731
27282732 _productAttributeService
27292733 . GetAllProductVariantAttributeCombinations ( product . Id )
27302734 . GetAllCombinationImageIds ( allCombinationImageIds ) ;
27312735
2732- PrepareProductDetailsPictureModel ( pictureModel , pictures , product . GetLocalized ( x => x . Name ) , allCombinationImageIds ,
2736+ PrepareProductDetailsPictureModel ( pictureModel , pictures , product . GetLocalized ( x => x . Name ) , allCombinationImageIds ,
27332737 false , bundleItem , m . CombinationSelected ) ;
27342738
2735- galleryHtml = this . RenderPartialViewToString ( "_ProductDetailsPictures" , pictureModel ) ;
2736- galleryStartIndex = pictureModel . GalleryStartIndex ;
2737- }
2738- }
2739+ galleryStartIndex = pictureModel . GalleryStartIndex ;
2740+ galleryHtml = this . RenderPartialViewToString ( "_ProductDetailsPictures" , pictureModel ) ;
2741+ }
2742+ }
27392743
27402744 #region data object
27412745 object data = new
@@ -2788,8 +2792,9 @@ public ActionResult UpdateProductDetails(int productId, string itemType, int bun
27882792 Availability = new { Text = m . StockAvailability , Show = product . DisplayStockAvailability , Available = m . IsAvailable }
27892793 } ,
27902794
2791- GalleryHtml = galleryHtml ,
2792- GalleryStartIndex = galleryStartIndex
2795+ DynamicThumblUrl = dynamicThumbUrl ,
2796+ GalleryStartIndex = galleryStartIndex ,
2797+ GalleryHtml = galleryHtml
27932798 } ;
27942799 #endregion
27952800
0 commit comments