问题
I have a custom attribute called visibility in CategoryModel and it can be changed both from backoffice manually and from a cronjob which checks whether there is at least one product under the category. If it is changed from backoffice, cronjob should not change the visibility even if any product is found under it. When an attribute is changed from backoffice, section called Last Changes in Backoffice registers changes related to attribute but I could not find how or where it is done.
How can I find out the place where an attribute of a model changes? From Backoffice or Cronjob or something like that?
回答1:
SavedValues - Keeping Track of Attribute Value Modification
If you modify the value of an attribute in Backoffice then the original value of the attribute (before modification) and the new value (after modification) stores in SavedValues. Early v6.7 there was HMC API to deal with SavedValues, but now you have to write the flexible query to get the entries from the service layer.
Find more detail here
Edit: Answer to your question
How can I find out the place where an attribute of a model changes? From Backoffice or Cronjob or something like that?
Find the attribute entry into the SavedValueEntry, if the current attribute value matches the newValue
, then it was modified from the backoffice otherwise from the cronjob.
Other references
savedvalues-in-hybris
how-to-access-savedvalues-and-savedvalue-entries
来源:https://stackoverflow.com/questions/52060379/finding-out-the-place-where-an-attribute-of-a-model-changes-in-hybris