on ‎2020 Nov 09 5:05 PM
Hello guys,
What are the steps or what is the best practice for adding a new parameter to an existing method of CommerceCartService?
Thanks in advance for your time and help.
Request clarification before answering.
The best practice is to extend CommerceCartParameter. In beans.xml, do something like:
<bean>
<property name="customProperty" type="String">
<description>My custom property</description>
</property>
...
</bean>See Extending CommerceCartService: https://help.sap.com/viewer/9d346683b0084da2938be8a285c0c27a/1905/en-US/8bbe2c6a866910149e5ff3b87c0b...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavel,
I can only share my opinion. I do not know what is your case, but something like this probably may work for you.
Of course don't forget to override the DefaultCommerceCartService to point to the extended version ExtendedDefaultCommerceCartService.
public class ExtendedDefaultCommerceCartService extends DefaultCommerceCartService implements ExtendedCommerceCartService {
@Overridepublic void recalculateCart(CommerceCartParameter parameter, boolean force, boolean newParam) throws CalculationException {
super.recalculateCart(parameter,force);
// do what ever you need to do with the newest parameter.
}
}Best Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.