November Happy Hour will be moved to Thursday December 5th.

Prepopulate empty AssociationGroup in catalog

Vote:
 

I'm working on a project where I would like to create empty associationgroups for items to avoid having editors/admins having to go into commerce manager and instead be able to work through the catalog admin view.

This is possible in the commerce manager UI as shown in this picture

Associationgroup UI

However I have not found a way to do this programmatically e.g when syncing the catalog from another system. Is this possible in any way?

Currently using versions

EPiServer.CMS version="8.11.0"
EPiServer.CMS.Core version="8.11.0"
EPiServer.CMS.UI version="8.6.0"
EPiServer.CMS.UI.Core version="8.6.0"
EPiServer.Commerce version="8.16.0"
EPiServer.Commerce.Core version="8.16.0"
EPiServer.Commerce.UI version="8.16.0"
EPiServer.Commerce.UI.ManagerIntegration version="8.16.0"
EPiServer.Framework version="8.11.0"

#142843
Jan 04, 2016 10:42
Vote:
 

Hi Pär,

I typically register these types at Startup with the following code inside an initialization module:

var associationDefinitionRepository = context.Locate.Advanced.GetInstance<GroupDefinitionRepository<AssociationGroupDefinition>>();
 
associationDefinitionRepository.Add(new AssociationGroupDefinition { Name = "MyGroup" });


I don't see why you couldn't incorporate this into an import process that registers new types that appear in new import files. I don't believe there are any restrictions that require their addition at startup, but I haven't tested that specifically.

Hope this helps,

/Matt

#142970
Jan 07, 2016 18:16
Vote:
 

Thank you Matthew, worked like a charm. Many thanks for seeing through my misguided attempts at solving it and providing a simple solution.

#142989
Jan 08, 2016 8:21
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.