Developer forum

Forum » Ecommerce - Standard features » ProductViewModel questions

ProductViewModel questions

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am trying to use the ProductViewModel object for the product feed used for lists.

So far, I have a few questions:

1. Is there any way I can easily format the prices? I see I can get Price.Formatted, PricewithVAT and PriceWithoutVAT but the last 2 are not formatted.

2. How can I handle StockLocations?

3. How do I handle CustomFields? Both ProductFields and ProductCategoryFields.

Thank you,

Adrian

 


Replies

 
Nicolai Pedersen
Reply

Hi Adrian

@1: Yes, I can see that. You can call Services.Currencies.Format to format the prices untill we release the properties.
I have added the missing properties to the viewmodel, TFS#81846, out with next hotfix of 9.8/Ecommerce 1.8.*

@2: You can only do that using the API for now. There will be a new model for handling units, stock and stocklocations that will be similar to how you know it from the new VariantInfo structure with 9.9

@3: By using the Prodfields and ProductCategories properties, https://doc.dynamicweb.com/api/html/6a619058-cb13-d177-147a-01f4576f6391.htm

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you very much.

For @2 until the new model, if I add a property in the index summing up the stock from all stock locations, will I be able to access it in the ProductViewModel?

I have a situation where the availability of the product is based on the stock from 2 stock locations.

Also, I have noticed that adding the Price property in the response affects the performance even if it's not Live pricing. Is there somthing I can do to improve performance for getting prices?

Thank you,

Adrian

 
Nicolai Pedersen
Reply

@2: Yes, but you will have to load the index, query it for the document with the autoid of the product, and then find the value. A simpler way would be to add the value to a custom field on the product - then it will be indexed automatically and will be in the ProductFields property of the productViewmodel.

 

You must be logged in to post in the forum