Developer forum

Forum » Ecommerce - Standard features » Replacement product cannot be set to point to a specific variant?

Replacement product cannot be set to point to a specific variant?

Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

I am trying to link to a specific variant that has replaced a phased out one, with following code

if (product is object)
{
string productName = product.Name;
 
if (product.ReplacementProduct is ProductInfoViewModel )
{
if (product.ReplacementProduct.ProductId != "")
{
var productService = new Dynamicweb.Ecommerce.Products.ProductService();
var replacementProduct = productService.GetProductById(product.ReplacementProduct.ProductId,product.ReplacementProduct.VariantId, true); 
 
etc etc
 
However, I only get back a ProductID from the replacementproduct PInfoViewModel... not variant. When I select a specific variant as replacement product in the PIM, there master product is listed in the replacement box, with no variant. Does this mean I can only ever redirect to the master of where the replacement variant is? This is not what I want

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Are you mistaking it with ProductViewModel (without the Info in its name)? ProductInfoViewModel looks like this:

public class ProductInfoViewModel : FillableViewModelBase
{
  public string ProductId { get; set; }
  public string VariantId { get; set; }
}

so it has no Number property.

 

You must be logged in to post in the forum