cancel
Showing results for 
Search instead for 
Did you mean: 

Reviewing changed Values in hybris Management Console

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

amitpanwar
Advisor
Advisor
0 Kudos

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.

Former Member
0 Kudos

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

El-jaoujat
Active Participant
0 Kudos

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.

Former Member
0 Kudos

Hi Youssef,

Thanks for the reply, but using an interceptor can duplicate changed information when we update the object via the HMC.

best regards, Mustapha.