Developer forum

Forum » Integration » Set products as disabled by default

Set products as disabled by default

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi guys,

I have a data integration job that gets basic product data from NAV, such as the number, name and price. These products need to be enriched in Dynamicweb before they can be activated. In my data source (from NAV) I can't tell if products are new, or already exist in Dynamicweb. How do I handle the Active flag? If I default to False, I am going to disable existing and previously activated products. If I default to true, they'll be true immediately.

I was thinking to use a table script, like this:

public override void ProcessInputRow(Mapping mapping, Dictionary<string, object> row)
{
  var productId = row["ProductID"].ToString();
  var product = Product.GetProductByID(productId);
  if (product == null)
  {
    row["ProductActive"] = false;
  }
  else
  {
    row["ProductActive"] = product.Active;
  }
}

This would check if the product exists and then use its current Active state. (I would optimize this a little further by fetching maybe all product IDs and Active states once first).

Does that make sense? Or is there an easier solution?

Imar


Replies

 
Dmitriy Benyuk
Reply

Hi Imar,
seems yes, this makes sense. Get all existing products at once and then check this in each ProcessInputRow.
Regards, Dmitrij

 

You must be logged in to post in the forum