Developer forum

Forum » Development » Related products in code

Related products in code

Vilius Janulis
Reply
Hi,

I have tried to made product have related products with no success .

Three ways i have tried:

/*
p.RelatedProducts.Add(new ProductRelated("PROD" + relatedProductid));
p.Save();
*/

/*
ProductRelatedCollection prc = new ProductRelatedCollection();
prc.Add(new ProductRelated("PROD" + relatedProductid));
p.Save();
*/

/*
ProductRelated prr = new ProductRelated();
prr.Save(p.ID, "PROD" + relatedProductid, "RELGRP4");
p.Save();
*/
I am getting error : "" even though i am checking with if statements if every value is null , empty and etc.

Ideas ? Thank you :)

relatedProductid - just an id value from other system so i am adding PROD in front.





Replies

 
Morten Snedker
Reply
This post has been marked as an answer
 Hi Vilius,

You're definitely on right track. I'm afraid it is the counter-intuitive design of the object that's leaving you behind!  :-)

You need to explicitly set both the properties and the overloads of the save method:

Dynamicweb.eCommerce.Products.ProductRelated pr = new Dynamicweb.eCommerce.Products.ProductRelated();
pr.ProdID = "101800"; //your main product
pr.ProdRelID = "990000"; //your related product
pr.RelGroupID = "RELGRP1"; //ID of related group
pr.Save(pr.ProdID, pr.ProdRelID, pr.RelGroupID);

Give it a go and let me know if it solves your problem!

Regards /Snedker
Votes for this answer: 0
 
Morten Snedker
Reply
 PS: http://developer.dynamicweb-cms.com/api/ecommerce/

/Snedker

 

You must be logged in to post in the forum