Developer forum

Forum » Dynamicweb 10 » Accessing ProductViewModel from Product field type in Item

Accessing ProductViewModel from Product field type in Item

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have had a similar post related to DW9, but it seems that I always get stuck with this field type.
I have an ItemType (Products) with a property of type ItemRelation (inline), connected to another ItemType (Product).
The second ItemType (Product) has a property of type "Product" allowing the admin to select a product.
I could easily read the first list using Model.Item.TryGetItems("Products", out var products)
This results in a list of ItemViewModel. This ItemViewModel has the property Product that I am trying to read.
In the foreach I have tried:
ProductListViewModel testViewModel = product.GetValue<ProductListViewModel>("Product");

ProductViewModel testViewModel = product.GetValue<ProductViewModel>("Product");

But none of them could produce a non-null result.
What am I missing?

Thank you,
Adrian


Replies

 

You must be logged in to post in the forum