Posted on 25/01/2022 12:27:24
This works fine for me in 9.10.13, but in 9.12.7 I get an error:
System.ArgumentNullException: Value cannot be null.
Parameter name: key
I am basically using the same code:
@if (field.SystemName.ToLower() == "Product_Selection".ToLower())
{
{
var productList = (Dynamicweb.Ecommerce.ProductCatalog.ProductListViewModel)itemViewModel.GetValue("Product_Selection");
<tr>
<td colspan="2">@productList.ToString()</td>
</tr>
if (productList == null)
{
continue;
}
if (productList.Products == null)
{
continue;
}
<tr>
<td> - </td>
<td>
<table border="1">
@foreach (var product in productList.Products)
{
<tr>
<td> - </td>
<td>@product.Name</td>
</tr>
}
</table>
</td>
</tr>
}
Would I need another approach to accessing the products in the ProductListViewModel in 9.12+?
Also, using Model.ToJson fails in both versions, but in 9.10 I get this message:
Newtonsoft.Json.JsonSerializationException: Error getting value from 'Price' on 'Dynamicweb.Ecommerce.ProductCatalog.ProductViewModel'. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: key
Thinking there could be a relation between that and the error I get in 9.12.
Any suggestions are highly appreciated.