Developer forum

Forum » Development » Problem creating a product

Problem creating a product


Reply
I am trying to create a new product by nothing happens, I don't get any exception or nothing - am i missing something??

code:

Dynamicweb.eCommerce.Products.Product newProduct = new Dynamicweb.eCommerce.Products.Product();

//   newProduct.ID = "prod5";
newProduct.Number = "fkjjkhf";
newProduct.LanguageID = "LANG1";
newProduct.Name = "name1";
newProduct.DefaultPrice = 103.5d; // netpris...
newProduct.LongDescription = "long desc";
newProduct.Save("prod5", string.Empty);

Best regards
Ole

Replies

 
Nicolai Høeg Pedersen
Reply
Does it not show up in database or in backend?

You probably need to put the product to a group before it shows up in the backend:

Dim pgr As New ProductGroupRelation(prodId, groupId)
pgr.ProductID = prodId
pgr.GroupID = groupId
pgr.Save(prodId, groupId)
 
Reply
It doesn't show up in the database...
I've tried your suggestion but it makes no difference - still nothing..

I've also tried it like this:

newProduct.Groups.Add(group);

but still no products

 
Nicolai Høeg Pedersen
Reply
It might also be your save statement with the product id parameter.

Have a look at this example:
http://engage.dynamicweb-cms.com/api/ecommerce/?Dynamicweb~Dynamicweb.eCommerce.Products.Product~Save().html
 
Reply
Thanks, that helped!!

I did try the save function with no parameters before, so I guess it was some default properties on the product object I needed to set.

The sample link you gave me worked.

Thanks again...

Best regards
Ole

PS! You don't need to put the product on a group for it to work..

If you want to put it on a group, you have to use the ProductGroupRelation object like this:

ProductGroupRelation pgr = new ProductGroupRelation();
pgr.GroupID = "GROUP25";
pgr.Sorting = 1;
pgr.ProductID = "prod6";
pgr.Save("prod6", "GROUP25");

 

You must be logged in to post in the forum