Developer forum

Forum » Development » Create products via front-end

Create products via front-end


Reply
Hi,

I wan't to create products via the front-end and use as much standard module as possible.
I've set up a form using the new form module to create a product in dbo.EcomProduct. This works fine, but the relation between the product and a giving groups is missing. 

So my questions are:
1. Is it possible to create a product via front-end. witch create both a product in the dbo.ecomproduct and at the same time makes the relation in the dbo.EcomGroupProductRelation only by using standard technic.

2. And is there a downside or a security risk by doing it this way?


/Rasmus

Replies

 
Reply
Hi Rasmus.
Sorry, but there is no standard technic to create a product from frondend.
 
Reply

You should use the API rather than the database directly.

The API for creating products is quite shaky, and you won't receive any exception messages, if Dynamicweb eCommerce choses not to save your product to the database. E.g. supplying a created and updated date is required, otherwise nothing happens.

For both Product and Group, I don't know which approach actually works: Using constructor arguments, populating class fields og using this actual Save overload,  but using all three usually works.

var productid = "prod1";
var groupid = "group1";

//Create product

new Product(productid, "", "LANG1"){
 ID = productid,
 Number = productid,
 Name = ProductID,
 Created = DateTime.Now,
 Updated = DateTime.Now,
 Active = true,
 LanguageID = "LANG1",
 VariantID = ""
}.Save(ProductID, "");
//Create product group relation

new ProductGroupRelation(productid, groupid){
 GroupID = groupid
 ProductID = productid
}.Save(productid, groupid);

Hopefully you can use it:)

BR.
Lars

 

You must be logged in to post in the forum