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

DataPolicyService methods

DataPolicyService methods

The com.elasticpath.service.datapolicy.DataPolicyService class provides methods to create, update, and read data policies.

DataPolicyService.save()

To add a new data policy:
  1. Add the data points to the data point collection in the DataPolicy object, by running:

    DataPolicy.getDataPoints().add(DataPoint); .

  2. Add a new datapolicy object by running:

    DataPolicyService.save(DataPolicy dataPolicy).

DataPolicy.update()

You can update a data policy by updating the datapolicy object using the update method.

DataPolicyService.update().

Note: You can modify settings for a data policy in the draft state only.

After modifying other properties of the data policy, update the data policy using the DataPolicyService.update() method.