LineItemId is -1

Vote:
 

Hi,

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);

_orderRepository.Save(cart);

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

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

Thanks!

/Jessica

#201843
Mar 05, 2019 10:38
Vote:
 

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. 

#201845
Mar 05, 2019 10:59
Vote:
 

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

#201846
Mar 05, 2019 11:35
Vote:
 

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. "

#201847
Mar 05, 2019 11:45
Vote:
 

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

Thanks Quan!

#201849
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.