on 02-25-2015 4:53 PM
Generally, if you modify the value of a hybris Multichannel Suite item attribute in the hybris Management Console (hMC), the original value is stored in the hybris Multichannel Suite's database. This process is run automatically. How can i activate this process when updating values from customized Application frontend ?
Note : using HMCManager.getInstance().logItemModification(item.getPK(), newValues, oldValues, true) is not a good solution for me.
Hi,
If you want to do it for specific types, you can make it an event and just publish that from your code and then write a listener which listens to respective event and creates saved value instance. This would ensure that there are no duplicates when you edit from HMC.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I assume it will depend on how exactly are you doing these updates, but I would suggest creating a function to manually create a SavedValues instance with its needed classes: https://wiki.hybris.com/display/release5/SavedValues+-+Keeping+Track+of+Attribute+Value+Modification
and calling it as needed, for example by creating a service which will create these log modification objects before calling modelService.save(myObject);
Then, you will need to call myModelService.Save(myObject), which will contain the log creation plus the actual call to modelService.save(myObject).
This is considering that you only want to keep the modifications of items in certain parts of your code, if you want to save any modification happening in the system, I would suggest as Youssef said an interceptor, where you could check if the modification has already been logged in before writing it, or write your own logItemModification method to avoid duplicates.
Hope that helps, Juan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can add an implementation of ValidateInterceptor
mapped with the Item
type code
and on the onValidate
methode do this :
@Override
public void onValidate(final ItemModel model, final InterceptorContext ctx) throws InterceptorException
{
String attributeName=ctx.getDirtyAttributes(model) //get the attributes that changed
String oldeValue // get the old value i think that modelService.getAttribut(attributeName);
String newValue // get the new value , i think that ctx.getAttribute(attributeName)
//Log your change
Saved values =JaloConnection.getInstance().logItemModification(item, values, previousValues, detectRemovedValues);
// persist the values
}
/!\ this may cause a big performance issues !
Youssef.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.