cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to track dirty attributes or modified attributes and its values when the user import data from HAC?

Former Member
2,368

Hi,

As part of the business, I want to track all modified attributes(Dirty attributes) and its values when data imported through HAC same like HMC or Backoffice will do.

Accepted Solutions (0)

Answers (3)

Answers (3)

arvind-kumar_avinash
Active Contributor

You can use ModelContextUtils.getItemModelContext(yourModel).getDirtyAttributes() e.g. by executing the following code in groovy console of hAC, you should be able to find all dirty attributes of the given model:

 import de.hybris.platform.servicelayer.model.ModelContextUtils
 
 exampleProduct = modelService.create('Product')
 exampleProduct.code = "12345"
 exampleProduct.catalogVersion = catalogVersionService.getCatalogVersion('Default', 'Staged')
  try {
      p = flexibleSearchService.getModelByExample exampleProduct
  } catch (e) {
      p = exampleProduct
  }
 
 ModelContextUtils.getItemModelContext(p).getDirtyAttributes()

You can also check my answer to a similar problem.

Former Member

Thank You for the response.

But that is not I am expecting. Whenever the data imported by the user from HAC those changes should be saved in SavedValues table and at the same time, those changes should be reflected on the back-office modified changes tab.

ychater
Discoverer
0 Kudos

Hello,

I think you are looking for Interceptors, here are some articles explaining that and how to implement them :

http://javainsimpleway.com/interceptors-in-hybris/
http://javainsimpleway.com/implementing-interceptor-in-hybris/

KR,

Youssef

former_member666301
Discoverer
0 Kudos
Former Member
0 Kudos

a simple solution would be as follows: yourmodel.getItemModelContext().getDirtyAttributes() to get the dirty attributes.

or if you just want to check if it has dirty attributes: yourmodel.getItemModelContext().isDirty()