SaaS CMS has officially launched! Learn more now.

LineItemId is -1



We are using serialized carts to store cart content. When saving the line item, I notice that the id for all line items are -1 in the SerializableCart-table in the database, whereas the line items have IDs in Commerce Manager. Is it supposed to be like that? Could we, when loading the cart and its line items, get hold of the line item id as seen in Commerce Manager? 

Here is an outline of what I'm doing when creating the cart.

var cart = _orderRepository.LoadOrCreateCart<ICart>(contactId, nameOfCart);

var lineItem = cart.CreateLineItem(code, _orderGroupFactory);

cart.AddLineItem(lineItem, _orderGroupFactory);


And later, when loading the created cart, the line item ids are all -1. Why is that?

var loadedCart =_orderRepository.LoadCart<ICart>(contactId, nameOfCart);



Mar 05, 2019 10:38

Hi - which version are you using? I'm quite sure the later version of Commerce fixed this issue. However for serializable carts, as long as the lineitemid is unique within a cart, it should not be a problem. 

Mar 05, 2019 10:59

We are using, is this a version where the issue would still exist?

Mar 05, 2019 11:35

I remembered it a bit reverse, so the fix actually make the id negative, so no worries, it's all fine. To answer your question - Is it supposed to be like that?  - yes. If you add another lineitem to the cart it should have id of -2.

My statement above still holds 

"However for serializable carts, as long as the lineitemid is unique within a cart, it should not be a problem. "

Mar 05, 2019 11:45

Great! I was just surprised over the negative id, but of course, its not a problem as long as they are unique.

Thanks Quan!

Mar 05, 2019 12:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.