Hi
I'm in the process of upgrading a Dynamicweb solution from v 8.X to v 9.4.
In the new version theres been some changes to the API, as listed here: https://doc.dynamicweb.com/downloads/releases/upgrading/dw9-api-cheatsheet
Amongst those is the change fra "eCommerce" to "Ecommerce", but also the Product.GetProductById method (https://doc.dynamicweb.com/api/html/bc85a251-d638-d667-f30b-5a9a0c96723a.htm) is now obsolete.
Unfortunately there is no reference to which method that can be used instead.
I'm trying to get some product info (ex. name, productnumber and categories) from within a paragraph template using the following code:
@{ string productid = System.Web.HttpContext.Current.Request.QueryString.Get("ProductID"); Dynamicweb.Ecommerce.Products.Product p = Dynamicweb.Ecommerce.Products.Product.GetProductByID(productid); string productname = p.Name; string productnumber = p.Number; string categoryName = p.GetCategories()[0].Name.ToLower(); }
The page this paragraph is inserted on is a page that displays a product.
I found the method ProductService.GetProductById (https://doc.dynamicweb.com/api/html/f273417e-3def-f13c-f4f4-77bf8c8215d6.htm), but this method takes three parameters instead of just the product id, and requires a product variant id - what if the product isn't a variant?
I have tried to modify my code to this instead:
@{ string productid = System.Web.HttpContext.Current.Request.QueryString.Get("ProductID"); Dynamicweb.Ecommerce.Products.Product p = Dynamicweb.Ecommerce.Products.ProductService.GetProductById(productid, "", true); string productname = p.Name; string productnumber = p.Number; string categoryName = p.GetCategories()[0].Name.ToLower(); }
But it returns this error message:
An object reference is required for the non-static field, method, or property 'Dynamicweb.Ecommerce.Products.ProductService.GetProductById(string, string, bool)'
Any suggestions as to how to get some product info from a paragraph template or what I'm doing wrong?
Best regards
Thomas