Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

ChangeSetService

ChangeSetService

The ChangeSetService provides methods for adding objects to and removing objects from Change Sets.

Adding objects to a Change Set

ChangeSetService changeSetService = beanFactory.getBean(ContextIdNames.CHANGESET_SERVICE);
Map<String, String> metadata = new HashMap<String, String>();

changeSetService.addObjectToChangeSet(changeSetGuid, object, metadata);

changeSetGuid is the Change Set GUID. The object parameter can be either a domain object (Product, Category, etc.) or a BusinessObjectDescriptor. The metadata map can be used to pass information during synchronization, for example, to pass Change Set update information to the Data Sync Tool.

Finding an object's Change Sets

An object can only belong to one active (non-finalized) Change Set at any given time. Use the ChangeSetService's findChangeSet methods to get an object's active Change Set.

Object domainObject
...
ChangeSet changeSet = changeSetService.findChangeSet(domainObject);

findChangeSet can take either a domain object (Product, Category, etc.) or a BusinessObjectDescriptor as a parameter.