Developer forum

Forum » Development » Create a new Product

Create a new Product


Reply

The Code

 

 

Product p = new Product();

GroupCollection grupos = Dynamicweb.eCommerce.Products.Group.getGroups();

            string grpID = "";

            foreach (Group grp in grupos)

            {

                if (grp.Number.Equals(csvItems[Stand]))

                {

                    isUnknownGroup = false;

                    grpID = grp.ID;

                    p.addGroup(grp);

                    break;

                }

}

 

            p.LanguageID = "LANG1";//There are other products with Language ID “LANG1”

 

            //' save product

 

//p.Save(p.ID,"");

            p.Save();

 

            ProductGroupRelation pgr = newProductGroupRelation();

            pgr.GroupID = grpID;

            pgr.ProductID = p.ID;

            pgr.Save(pgr.ProductID, pgr.GroupID);

            writeLog("Resultado Save And Confirm : " + p.SaveAndConfirm(p.ID, ""), false);

            writeLog("produto criado -> " + p.ID, false);

 

 

The LOG file

 

Resultado Save And Confirm : False

produto criado -> PROD2331

Resultado Save And Confirm : False

produto criado -> PROD2332

Resultado Save And Confirm : False

produto criado -> PROD2333

Resultado Save And Confirm : False

produto criado -> PROD2334

Resultado Save And Confirm : False

produto criado -> PROD2335

 

 

 

Looking at my LOG File I can see that the ID is correct but the SaveAndConfirm method return’s false.

But the most important thing is that the product isn’t created in the database


Replies

 
Reply
Hi Humberto,

Try using the product Save(productID, VariantID) overload. Let me know how it goes.


Regards
Morten Snedker
 
Reply
Oh, I see you already tried that. Try with the overload still, but by setting the productID explicitly, ie

p.Save("TestProduct", String.Empty);

Regards
Morten Snedker
 
Reply
It's working, THANKS!!

 

You must be logged in to post in the forum