on 2019 May 22 4:12 PM
Going by the ideal approach of extending OOB itemtypes, I tried below to extend my OOB Cart Itemtype
< itemtype code="MyCart" extends="Cart" jaloclass="com.core.MyCart" autocreate="true" generate="true" >
<description> Extending Cart type with additional attributes < /description >
< attributes >
< attribute autocreate="true" qualifier="myAttribute" type="java.lang.String" >
< description >Custom Attribute in the cart model< /description >
< persistence type="property" />
< /attribute >
< /attributes >
< /itemtype >
While trying to set the value in my extended DefaultCartFacade as below, I am getting Classcastexception.
final CartModel cartModel = defaultCartService.getSessionCart();
((MyCartModel)cartModel).setMyAttribute("str");
Is it required to instantiate an instance of MyCartModel by extending DefaultCartService#internalGetSessionCnd return MyCartModel object. Am I missing on something?
Request clarification before answering.
Hi Instead of creating a new item type by extending the cart use the existing cnd add attribute as follows where
autocreate="false"
then it might work and do not create a new item type. Hope this might help.
<itemtype code="Cart" autocreate="false" generate="false">
<description> Extending Cart type with additional attributes < /description >
< attributes >
< attribute autocreate="true" qualifier="myAttribute" type="java.lang.String" >
< description >Custom Attribute in the cart model< /description >
< persistence type="property" />
< /attribute >
< /attributes >
</itemtype>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Exactly thats what I followed in my previous projects where there were hardly 1-2 additional attributes and were common to all Business processes, but with the new requirements I have a number of attributes >5 to be added and was considering the approach to create a new item type to extend the OOB itemtype.
Eventually, understanding the extent of customization required, we thought of going ahead with the known approach.
shaktimohanty Let me know how you implemented.As i want to extend cart itemtype.
Can you help me what all customization required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have just created an item type. But you need to set the Mycart in JaloSession and then try to retrieve it . Infact, when you create a new cart, you should create a new cart of type mycnd not cart.
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.