Calling Cart.AcceptChanges() in Session_Start

Vote:
 

I am seeing this error in my logs:

..

Message: Mediachase.Commerce.Orders.Exceptions.OrderException: A cart with same CustomerId, Name, and MarketId already exist. Creating duplicated cart is not allowed
   at Mediachase.Commerce.Storage.MetaStorageBase.ProcessInsertUpdateResults(DataResult result)
   at Mediachase.Commerce.Storage.MetaStorageBase.AcceptChanges(MetaDataContext context, Boolean saveSystem)
   at Mediachase.Commerce.Orders.OrderGroup.AcceptChanges()
   at Mediachase.Commerce.Orders.Cart.AcceptChanges()
   at GA.Web.UI.Global.Session_Start(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Web.SessionState.SessionStateModule.CompleteAcquireState()
   at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

...

I notice that it is coming from Session_Start.  The error seems to show that Session_Start is calling Cart.AcceptChanges() directly.  But this surprises me, because I do not directly call Cart.AcceptChanges().

(I DO have some other objects in Session_Start that can indirectly call Cart.AcceptChanges() through nested function calls.. but, the stack trace shows that Cart.AcceptChanges() is being called directly.)

So I'm a bit confused about what could be happening here.. any ideas?

EDIT:

I'm using EPiServer Commerce Framework
Version: 9.24 (build: 1)

#174106
Edited, Jan 18, 2017 22:27
Vote:
 

Hi,

GA.Web.UI.Global.Session_Start(Object sender, EventArgs e)

is this your code? Can you post it here?

#174115
Jan 19, 2017 9:56
Vote:
 

Hi Quan,

I wasn't able to post all the code.  But It's okay, I was able to solve the problem :)

I understand that this error can happen if you create two new carts for a user and attempt to save them both...  I located a spot in our code where this could potentially be happening... so I refactored it accordingly - and haven't gotten this error since.

Thanks,

 - Ken

#174263
Jan 23, 2017 17:24
Vote:
 

Yes, we made that change long ago to ensure that a customer can only have one cart per market at a time. Otherwise it will be problematic when you load it (which cart to load etc.). It's good that you fixed your problem 

#174264
Jan 23, 2017 17:32
* 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.