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

Finding out the place where an attribute of a model changes in Hybris

Former Member
0 Likes
1,801

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?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

I assume this visibility attribute is a boolean value. True means visible and false means not visible.

Now a simple way to achieve what you wish to do is rather than having a boolean value, have a string value.

  1. value 'A' means visible to users but edited from backoffice requesting Mr. Cronjob to not touch it.

  2. value 'B' means visible to users but edited from backoffice allowing Cronjob to change/update it.

  3. value 'C' means not visible to users but edited from backoffice requesting Mr. Cronjob to not touch it.

  4. value 'D' means not visible to users but edited from backoffice allowing Cronjob change/update it.

  5. blank value means not visible to users but cronjob can update it.

so rather than your website manager changing the visibility to true/false, he can change it to A/C and cronjob won't touch it.

Hope it helps.

mpern
Product and Topic Expert
Product and Topic Expert
0 Likes

why not an Enum instead of string :)

Former Member
0 Likes

: Enum is better, I was guiding in the right direction.

Former Member
0 Likes

related to attribute but I could not find how or where it is done.

it's called Saved values mechanism, however not sure that it will satisfy your requirement completely because how can you guarantee that change detected in the saved values is THE last change? I would recommend making your visibility attribute a bit more complex and write down along with actual value also the system made last change. In such a way you will always know what component made the last change.

Former Member
0 Likes

Maybe a Interceptor would help here. Had a similar issue many years ago. You can add logs and search if a backoffice user did the changes etc. Check here for more informations: https://help.hybris.com/1808/hcd/8bfbf43e8669101480d0f060d79b1baa.html