Bulk Weight Update In Product Master

Good evening,

We are looking to bulk update the weight for the parts in the product master.

Can you please provide sample code to reflect this connection and processing?



Hello Joseph. Will you be using C# or VB.NET?

Avontus Dev

C# is fine.

Thank you


Hi Joseph. Here you go. I’m not sure what source you’ll be reading from so I’ve just put this in a generic while loop. I’m also assuming that you have a part number in the source. Also notice that we’re loading ProductType.Product, which is the product catalog. If you want to do this with consumables you’ll want to load the ProductType.Consumable. Hope this helps!

while ([read info from source])
    string partNumber = GetFromSource;
    double? weight = GetFromSource;
    Product prod = Product.GetProduct(partNumber, ProductType.Product);

    // If the product was found then the part number
    // will be the same
    if (prod.PartNumber == partNumber)
        prod.Weight = newWeight;

        // Now determine if the product is able to be saved
        // and save if so, otherwise warn
        if (prod.IsSavable)
            prod = prod.Save();
            Console.WriteLine("Error saving part '" + partNumber + "' " + prod.BrokenRulesCollection.ToString());