I am using nopCommerce 2.8.
I am trying to pull a list of product attributes and their values.
My code pulls a list of product attributes, but I cannot pull the value for this order:
Job Name: fedd
I can pull the name, but not the value.
Here is my code:
IOrderService orderService = EngineContext.Current.Resolve<IOrderService>();
IProductAttributeParser productAttributeParser = EngineContext.Current.Resolve<IProductAttributeParser>();
IProductAttributeService productAttributeService = EngineContext.Current.Resolve<IProductAttributeService>();
Order od = orderService.GetOrderById(106600);
foreach (OrderProductVariant ov in od.OrderProductVariants)
{
StringBuilder builder = new StringBuilder();
//builder.Append(ov.AttributeDescription);
List<ProductVariantAttribute> attrs = productAttributeParser.ParseProductVariantAttributes(ov.AttributesXml).ToList();
foreach(var attr in attrs)
{
Response.Write("Name: " + attr.ProductAttribute.Name + "<br />");
var val = productAttributeService.GetProductAttributeById(attr.ProductAttributeId);
if (val != null)
Response.Write(val.Name + " " + val.Description + "<br />");
else
Response.Write("No values.<br />");
}
}
Here is the end result:
Name: Card Thickness
Card Thickness
Name: Job Name
Job Name
Name: Printing Options
Printing Options
Name: Artwork
Artwork
Name: Production Time
Production Time
Name: Proofs
Proofs