bleroy / Nwazet.Commerce

Idiomatic commerce module for Orchard CMS.
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

ProductImage not displayed in shopping cart #64

Closed bleroy closed 8 years ago

bleroy commented 9 years ago

Originally reported by: Anonymous


Thanks for that awesome module Betrand.

I am facing an issue with ProductImage not being displayed in Shopping cart view:

#!c#

private IEnumerable<dynamic> GetProductShapesFromQuantities(
            IEnumerable<ShoppingCartQuantityProduct> productQuantities) {
            var productShapes = productQuantities.Select(
                productQuantity => _shapeFactory.ShoppingCartItem(
                    Quantity: productQuantity.Quantity,
                    Product: productQuantity.Product,
                    Sku: productQuantity.Product.Sku,
                    Title: _contentManager.GetItemMetadata(productQuantity.Product).DisplayText,
                    ProductAttributes: productQuantity.AttributeIdsToValues,
                    ContentItem: (productQuantity.Product).ContentItem,

                 ProductImage: ((dynamic)productQuantity.Product.ContentItem).Product.ProductImage.MediaParts[0],

                     //((MediaLibraryPickerField) productQuantity.Product.Fields.FirstOrDefault(f => f.Name == "ProductImage")),

                    IsDigital: productQuantity.Product.IsDigital,
                    Price: productQuantity.Product.Price,
                    DiscountedPrice: productQuantity.Price,
                    LinePriceAdjustment: productQuantity.LinePriceAdjustment,
                    Promotion: productQuantity.Promotion,
                    ShippingCost: productQuantity.Product.ShippingCost,
                    Weight: productQuantity.Product.Weight,
                    MinimumOrderQuantity: productQuantity.Product.MinimumOrderQuantity)).ToList();                    
            return productShapes;
        }

productQuantity.Product.Fields is empty. Changed code here to

#!c#

ProductImage: ((dynamic)productQuantity.Product.ContentItem).Product.ProductImage.MediaParts[0],

and it worked for me.

Additionaly needed to Change in ShoppingCart.cshtml:

#!c#

item.ProductImage.Url 

to

#!c#

item.ProductImage.MediaUrl 

Is this a general issue or just happening here?

Thanks Dieter


bleroy commented 9 years ago

Original comment by Dieter Schüle (Bitbucket: dpomt, GitHub: dpomt):


Done: https://bitbucket.org/bleroy/nwazet.commerce/pull-request/28/shoppingcart-fix-for-product-image-not/diff

bleroy commented 9 years ago

Original comment by Bertrand Le Roy (Bitbucket: bleroy, GitHub: bleroy):


Can you make a pull request?