Hi everyone,
How can I interract with assortments in API?
I need to:
- Create new assortment,
- Asign a user/user group,
- Asign product/product group to that newly created assortment.
/Martin
Hi everyone,
How can I interract with assortments in API?
I need to:
/Martin
Well, this is how far we came with this:
var assort = new Assortment(); assort.ID = "ASSORTMENT1"; assort.Number = "ASSORTMENT1"; assort.Name = "ASSORTMENT1"; assort.LanguageID = "LANG1";
But I can't see any way to add a product, or asign product to an assortment,
Same issue about the User aswell.
The only way I can see I can "Fill" the assortment is through "DataReader"
But I hope there is an easyer way to do it?
/Martin
Hi Martin,
hers is a sample code for that:
//Create new assortment
Dynamicweb.eCommerce.Assortments.Assortment assortment = new Dynamicweb.eCommerce.Assortments.Assortment();
assortment.Name = "AssortmentName";
assortment.Active = true;
assortment.Save();
//Asign a user
Dynamicweb.Modules.UserManagement.User user = Dynamicweb.Modules.UserManagement.User.GetUsers().FirstOrDefault();
Dynamicweb.eCommerce.Assortments.AssortmentPermission userPermission = new Dynamicweb.eCommerce.Assortments.AssortmentPermission(assortment, user);
userPermission.Save();
//Assign a user group
Dynamicweb.Modules.UserManagement.Group userGroup = Dynamicweb.Modules.UserManagement.Group.GetGroups().FirstOrDefault();
Dynamicweb.eCommerce.Assortments.AssortmentPermission groupPermission = new Dynamicweb.eCommerce.Assortments.AssortmentPermission(assortment, userGroup);
groupPermission.Save();
//Asign group to newly created assortment
Dynamicweb.eCommerce.Products.Group group = Dynamicweb.eCommerce.Products.Group.GetAllGroups().FirstOrDefault();
Dynamicweb.eCommerce.Assortments.AssortmentGroupRelation assortmentGroupRelation = new Dynamicweb.eCommerce.Assortments.AssortmentGroupRelation(assortment, group);
assortmentGroupRelation.Save();
//Asign product to newly created assortment
Dynamicweb.eCommerce.Products.Product product = Dynamicweb.eCommerce.Products.Product.GetAllProducts().FirstOrDefault();
Dynamicweb.eCommerce.Assortments.AssortmentProductRelation assortmentProductRelation = new Dynamicweb.eCommerce.Assortments.AssortmentProductRelation(assortment, product);
assortmentProductRelation.Save();
Worked like a charm, thank you Dmitriy :-)
You must be logged in to post in the forum