The ProductName and ProductImageUrl is not available in LineItem of Model.ContentItem.Content.OrderPart.LineItems when I customize SummaryAdmin view of Order #632
-
|
Hi @sarahelsaig , The ProductName and ProductImageUrl is not available in LineItem of Model.ContentItem.Content.OrderPart.LineItems when I customize SummaryAdmin view of Order. Can you Provide properties of LineItem in SummaryAdmin View like the LineItem in OrderPart.cshtml? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
You can look up the content item using @inject IProductService ProductService
@foreach (var lineItem in Model.OrderPart.LineItems)
{
var item = (await ProductService.GetProductsByContentItemVersionsAsync([lineItem.ContentItemVersion]))
.SingleOrDefault();
var name = item?.ContentItem.DisplayText;
var image = item?.ProductImage.Paths?.FirstOrDefault();
} |
Beta Was this translation helpful? Give feedback.
You can look up the content item using
IProductServiceby passing theOrderLineItem.ContentItemVersionproperty to get the exact version used at the time of purchase (product content types should always be Versionable, so this will return the version used at the time of purchase, even if the content item has changed since then). For example in OrderPart.cshtml you can do this: