/// <summary>
/// Get product image from IProductContent Model
/// </summary>
/// <param name="iProductContent">This model is provided by view file when it call to view product image</param>
/// <example>_ProductBox.cshtml</example>
/// <returns></returns>
public static System.Collections.Generic.List<string> GetProductImageFromModel(Merchello.Web.Models.VirtualContent.IProductContent iProductContent)
{
System.Collections.Generic.List<string> images = new System.Collections.Generic.List<string>();
var properties = iProductContent.Properties;
foreach (var pro in properties)
{
if (pro.PropertyTypeAlias == "image")
{
var id = pro.DataValue;
var umbHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
var content = umbHelper.Media(id);
images.Add(content.Url);
}
}
return images;
}
Somehow Model.GetPropertyValue<List<IPublishedContent>> doesn't work. So I have to look into its property value and try to take image Id to find image url.
Merchello 2.7.1 cannot load product's image on home page
Hi all,
I have downloaded Merchello from github and start Merchello.FastTrack.Ui. But when the website is loading it generated an error:
var images = Model.GetPropertyValue<List<IPublishedContent>>("image");
images return null andimages.Any()
will generate exception.Because the product's cannot beloaded, then the home page cannot show the products.
Note: When I view the products from admin side, the product's images are available.
Here is my solution with a custom function:
Somehow
Model.GetPropertyValue<List<IPublishedContent>>
doesn't work. So I have to look into its property value and try to take image Id to find image url.is working on a reply...