You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Suraj Khurana <su...@hotwaxsystems.com> on 2017/05/09 05:01:55 UTC

Unused attributes of ShoppingCart and ShoppingCartItem

Hi Devs,

I am curious about some protected data members of ShoppingCartItem and
ShoppingCart class.
ShoppingCartItem contains:



*private Map<String, String> orderItemAttributes = null;private Map<String,
Object> attributes = null;*
While ShoppingCart have:

*private Map<String, String> orderAttributes = FastMap.newInstance();*
*private Map<String, Object> attributes = FastMap.newInstance();*

I think orderAttributes and orderItemAttributes are pretty clear by the
name itself, what is the actual use of *attributes* data member for each
class.

Can this be removed and replaced with orderAttribute or orderItemAttribute
itself?

--
Thanks and Regards,
Suraj Khurana
Sr. Enterprise Software Engineer
HotWax Systems - The global leader in innovative enterprise commerce
solutions powered by Apache OFBiz.

Re: Unused attributes of ShoppingCart and ShoppingCartItem

Posted by Arun Patidar <ar...@hotwaxsystems.com>.
+1 Suraj,
If value of 'attributes' is not getting populated in DB then it should be
replaced.

-- 
Thanks & Regards
---
Arun Patidar
Manager, Enterprise Software Development


HotWax Systems Pvt Ltd.www.hotwaxsystems.com


On Tue, May 9, 2017 at 10:31 AM, Suraj Khurana <
suraj.khurana@hotwaxsystems.com> wrote:

> Hi Devs,
>
> I am curious about some protected data members of ShoppingCartItem and
> ShoppingCart class.
> ShoppingCartItem contains:
>
>
>
> *private Map<String, String> orderItemAttributes = null;private Map<String,
> Object> attributes = null;*
> While ShoppingCart have:
>
> *private Map<String, String> orderAttributes = FastMap.newInstance();*
> *private Map<String, Object> attributes = FastMap.newInstance();*
>
> I think orderAttributes and orderItemAttributes are pretty clear by the
> name itself, what is the actual use of *attributes* data member for each
> class.
>
> Can this be removed and replaced with orderAttribute or orderItemAttribute
> itself?
>
> --
> Thanks and Regards,
> Suraj Khurana
> Sr. Enterprise Software Engineer
> HotWax Systems - The global leader in innovative enterprise commerce
> solutions powered by Apache OFBiz.
>

Re: Unused attributes of ShoppingCart and ShoppingCartItem

Posted by Martin Becker <ma...@ecomify.de>.
Yes indeed, Deepak.

Some additional infos:

* With the definition of ShoppingCartItem.attributeNames you are able to get context entries auto added to the „attributes“ Map within ShoppingCartHelper.addToCart. Such attributes may than be used, as described by Deepak, to be persisted anywhere or to just influence the checkout process. Those attributes are not necessarily to be persistet, they may be temporarily attributes like tokens or else just for the current checkout logic.

* The automatic adding of orderItemAttributes is controlled by the order.properties property „order.item.attr.prefix“. All context entries with this prefix (e.g. from an addToCart form) get added to the orderItemAttributes by ShoppingCartHelper.addToCart method.

* It is also possible to distinguish cart items by different attribute (and orderItemAttribute) values because of their relevance within the ShoppingCartItem.equals method

In my opinion the attribute maps differ fairly from the straightly domain model orderAttribute/orderItemAttribute ones and are not obsolete.

Regards

Martin Becker
www.ecomify.de


> Am 09.05.2017 um 09:02 schrieb Deepak Dixit <de...@hotwaxsystems.com>:
> 
> I think purpose of attributes is different, if you want to set some custom
> attribute to implement custom flow so you can use attribute.
> These attribute value can be store in any entity or can be used to perform
> business logic implementation as well.
> 
> Like in case of ShoppingCartItem, we set fromInventoryItemId as item
> attribute and while creation order item we copy this field to
> OrderItem.fromInventoryItem.
> 
> And if you want to store attribute in order or item level then you use
> orderAttributes or orderItemAttributes.
> 
> Thanks & Regards
> --
> Deepak Dixit
> www.hotwaxsystems.com
> 
> On Tue, May 9, 2017 at 10:31 AM, Suraj Khurana <
> suraj.khurana@hotwaxsystems.com> wrote:
> 
>> Hi Devs,
>> 
>> I am curious about some protected data members of ShoppingCartItem and
>> ShoppingCart class.
>> ShoppingCartItem contains:
>> 
>> 
>> 
>> *private Map<String, String> orderItemAttributes = null;private Map<String,
>> Object> attributes = null;*
>> While ShoppingCart have:
>> 
>> *private Map<String, String> orderAttributes = FastMap.newInstance();*
>> *private Map<String, Object> attributes = FastMap.newInstance();*
>> 
>> I think orderAttributes and orderItemAttributes are pretty clear by the
>> name itself, what is the actual use of *attributes* data member for each
>> class.
>> 
>> Can this be removed and replaced with orderAttribute or orderItemAttribute
>> itself?
>> 
>> --
>> Thanks and Regards,
>> Suraj Khurana
>> Sr. Enterprise Software Engineer
>> HotWax Systems - The global leader in innovative enterprise commerce
>> solutions powered by Apache OFBiz.
>> 


Re: Unused attributes of ShoppingCart and ShoppingCartItem

Posted by Deepak Dixit <de...@hotwaxsystems.com>.
I think purpose of attributes is different, if you want to set some custom
attribute to implement custom flow so you can use attribute.
These attribute value can be store in any entity or can be used to perform
business logic implementation as well.

Like in case of ShoppingCartItem, we set fromInventoryItemId as item
attribute and while creation order item we copy this field to
OrderItem.fromInventoryItem.

And if you want to store attribute in order or item level then you use
orderAttributes or orderItemAttributes.

Thanks & Regards
--
Deepak Dixit
www.hotwaxsystems.com

On Tue, May 9, 2017 at 10:31 AM, Suraj Khurana <
suraj.khurana@hotwaxsystems.com> wrote:

> Hi Devs,
>
> I am curious about some protected data members of ShoppingCartItem and
> ShoppingCart class.
> ShoppingCartItem contains:
>
>
>
> *private Map<String, String> orderItemAttributes = null;private Map<String,
> Object> attributes = null;*
> While ShoppingCart have:
>
> *private Map<String, String> orderAttributes = FastMap.newInstance();*
> *private Map<String, Object> attributes = FastMap.newInstance();*
>
> I think orderAttributes and orderItemAttributes are pretty clear by the
> name itself, what is the actual use of *attributes* data member for each
> class.
>
> Can this be removed and replaced with orderAttribute or orderItemAttribute
> itself?
>
> --
> Thanks and Regards,
> Suraj Khurana
> Sr. Enterprise Software Engineer
> HotWax Systems - The global leader in innovative enterprise commerce
> solutions powered by Apache OFBiz.
>