on 07-14-2016 9:45 AM
Hi all,I am a in Hybris and had a doubt.I am working on a project and it required to have an attribute such that it's default value is set dynamically but the value can be modified from hmc.Normal attributes are static so they won't allow business logic.Will dynamic attributes work here as I am not sure whether they can be modified from hMC?
Your use case is exactly what the Init Defaults Interceptor was made for.
The Init Defaults Interceptor is called when a model is filled with its default values. This happens either when it is created via the
modelService.create
method or when themodelService.initDefaults
method is called. You can use this interceptor to fill the model with additional default values, apart from the values defined in theitems.xml
file
Make sure you're registering the interceptor correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rachit,
You can set dynamic value for an attribute, but you CANNOT change its value via hMC, i.e modified value is not persisted
Regards, Chaitu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rachit,
Yes you can create a dynamic attribute and write your desired business logic inside the DynamicAttributeHandler class.
For reference, please check the link below: https://wiki.hybris.com/display/release5/Dynamic+Attributes
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.