I am using below code for this and not able to find the way to set the old value, new value and OldValueAttributeDescriptor for the savedValueEntryModel
Please provide help with the api code for storing the same and the code will work for all the attributes in the product model along with the classification attributes (product feature) in the product model.
final SavedValuesModel savedValuesModel = modelService.create(SavedValuesModel.class); final SavedValueEntryModel savedValueEntryModel = modelService.create(SavedValueEntryModel.class); savedValuesModel.setModificationType(SavedValueEntryType.CHANGED); savedValuesModel.setModifiedItem(product); savedValuesModel.setModifiedItemType(typeService.getComposedTypeForClass(ProductModel.class)); savedValuesModel.setModifiedItemDisplayString("Product '" + product.getCode() + "' (" + product.getPk().getLongValueAsString() + ")"); savedValuesModel.setUser(userService.getCurrentUser()); savedValuesModel.setTimestamp(new Date()); modelService.save(savedValuesModel);
savedValueEntryModel.setParent(savedValuesModel);
savedValueEntryModel.setModifiedAttribute(qualifier);
savedValueEntryModel.setOldValueAttributeDescriptor(typeService.getAttributeDescriptor(ProductModel._TYPECODE, qualifier));
savedValueEntryModel.setOldValue(originalValue);
savedValueEntryModel.setNewValue(updatedValue);
modelService.save(savedValueEntryModel);