It seems to me that your database was not properly migrated. When you upgrade to Commerce 12, IOrderGroup.Market was obsoleted, and we now store other properties of the market instead. The upgrade script would have taken care of those changes, but it's possible that it was not run properly, or one ore more of your carts were in a deleted market (so it can't match the data).
You didn't mention which cart system you are using, but assuming you are using SerializableCart, I'd suggest to look into that SerializableCart table to see if MarketId column is null for anything. If not, check OrderGroup table for null MarketId row.
Hi Quan,
You are correct, we're using the SerializableCart and we found a small subset of carts that indeed do not contain the new marketId property.
Thinking of a potential solution for this. Do this table hold references to other tables? Or should it be safe to remove these carts from the SerializableCart table?
/Emil
Now I looked more closely into it, SerializableCart has had MarketId since the beginning, and it's not allowed to be null... Same for OrderGroup.
So I was (partly) wrong. Did you delete the Default market somehow?
I can't remember we have removed the default market. It is deactivated however.
The number of carts that do not have the marketId is a total of 14 out of 21000.
The created timestamp of those 14 actually range very closely to the upgrade date.
/Emil
Before, or after? :). If it's after, are there other (OK) carts created after the upgrade?
Well, deleting them is one option, but I really want to get to the bottom of this.
If you are in a hurry, then it's probably safer to set the marketid for those carts to DEFAULT, to make CM works instead of just deleting them.
It was deactivated before the migration. There are new carts that are created after the upgrade and I can list them in the CM without breaking. However when trying to inspect a specific cart we get this error
[InvalidCastException: Unable to cast object of type 'EPiServer.Commerce.Order.Internal.SerializableOrderForm' to type 'Mediachase.Commerce.Orders.OrderForm'.] Mediachase.Commerce.Manager.Apps_Code.Order.OrderHelper.GetDiscountNamesList(IOrderForm orderForm, ILineItem lineItem) +648 Mediachase.Commerce.Manager.Apps.Order.Modules.<GetOrderLineItems>d__36.MoveNext() +1601 Mediachase.Commerce.Manager.Apps.Order.Modules.RelatedEntityView.LoadDataAndDataBind() +472 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +190 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.MakeDataBindColl(ControlCollection coll, Object obj) +245 Mediachase.BusinessFoundation.XmlFormBuilder.OnInnerDataBind(Object sender, EventArgs e) +44 Mediachase.BusinessFoundation.XmlFormBuilder.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +75 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +97 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +168 Mediachase.Commerce.Manager.Apps.Order.Modules.OrderView.Page_Load(Object sender, EventArgs e) +1180 System.Web.UI.Control.OnLoad(EventArgs e) +96 System.Web.UI.Control.LoadRecursive() +154 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Control.LoadRecursive() +251 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2168
Here is an example on a new serialized cart after the upgrade
{ "id": 24970, "created": "2018-05-24T06:49:38.093Z", "currency": "EUR", "customerId": "<hide>", "forms": [ { "orderFormId": -1, "authorizedPaymentTotal": 0.0, "capturedPaymentTotal": 0.0, "handlingTotal": 0.0, "name": "Default", "shipments": [ { "shipmentId": -1, "shippingMethodId": "<hide>", "shippingMethodName": null, "shippingAddress": { "id": "Shipping Address: ()", "firstName": null, "lastName": null, "organization": null, "line1": null, "line2": null, "city": null, "countryCode": "SWE", "countryName": null, "postalCode": null, "regionCode": null, "regionName": null, "daytimePhoneNumber": null, "eveningPhoneNumber": null, "faxNumber": null, "email": null, "properties": { "locale": { "$type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "$value": "en" }, "vatId": null } }, "shipmentTrackingNumber": null, "orderShipmentStatus": 1, "pickListId": null, "warehouseCode": "default", "lineItems": [ { "lineItemId": -1, "code": "<hide>", "displayName": null, "placedPrice": 11.2, "quantity": 3.0, "returnQuantity": 0.0, "inventoryTrackingStatus": 0, "isInventoryAllocated": false, "isGift": false, "properties": {}, "allowBackordersAndPreorders": false, "inStockQuantity": 0.0, "backorderQuantity": 0.0, "preorderQuantity": 0.0, "inventoryStatus": 0, "maxQuantity": 0.0, "minQuantity": 0.0, "entryAmount": 0.0, "orderAmount": 0.0, "taxCategoryId": 1, "salesTax": 0.0, "isSalesTaxUpToDate": true } ], "properties": { "locale": { "$type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "$value": "en" }, "vatId": null }, "shipmentDiscount": 0.0, "isShippingCostUpToDate": true, "isShippingTaxUpToDate": true, "shippingCost": 3.2, "shippingTax": 0.0, "operationKeys": {} } ], "promotions": [], "couponCodes": [], "payments": [], "properties": { "locale": { "$type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "$value": "en" }, "vatId": null } } ], "market": null, "marketId": "ROW", "marketName": "ROW", "pricesIncludeTax": false, "modified": "2018-05-24T06:49:45.5617948Z", "name": "Default", "notes": [], "orderLink": { "orderGroupId": 24970, "name": "Default", "customerId": "<hide>", "orderType": "EPiServer.Commerce.Order.Internal.SerializableCart, EPiServer.Business.Commerce, Version=12.2.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7" }, "orderStatus": 4, "organization": null, "properties": { "locale": { "$type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "$value": "en" }, "vatId": null }, "isTaxTotalUpToDate": true, "taxTotal": 0.0 }
Here is one of the carts that failed
{ "id": 24334, "created": "2018-05-22T09:07:14.383Z", "currency": "EUR", "customerId": "<hide>", "forms": [ { "orderFormId": -1, "authorizedPaymentTotal": 0.0, "capturedPaymentTotal": 0.0, "handlingTotal": 0.0, "name": "Default", "shipments": [ { "shipmentId": -1, "shippingMethodId": "00000000-0000-0000-0000-000000000000", "shippingMethodName": null, "shippingAddress": { "id": "Shipping Address: ()", "firstName": null, "lastName": null, "organization": null, "line1": null, "line2": null, "city": null, "countryCode": "SWE", "countryName": null, "postalCode": null, "regionCode": null, "regionName": null, "daytimePhoneNumber": null, "eveningPhoneNumber": null, "faxNumber": null, "email": null, "properties": {} }, "shipmentTrackingNumber": null, "orderShipmentStatus": 1, "pickListId": null, "warehouseCode": null, "lineItems": [], "properties": {}, "shipmentDiscount": 0.0, "operationKeys": {} } ], "promotions": [], "couponCodes": [], "payments": [], "properties": {} } ], "market": "ROW", "modified": "2018-05-22T09:07:14.7129498Z", "name": "Default", "notes": [], "orderLink": { "orderGroupId": 24334, "name": "Default", "customerId": "<hide>", "orderType": "EPiServer.Commerce.Order.Internal.SerializableCart, EPiServer.Business.Commerce, Version=11.8.3.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7" }, "orderStatus": 4, "organization": null, "properties": {} }
Regarding
[InvalidCastException: Unable to cast object of type 'EPiServer.Commerce.Order.Internal.SerializableOrderForm' to type 'Mediachase.Commerce.Orders.OrderForm'.]
IIRC then this was because WorkflowsVNext was not enabled in ecf.app.config
Back to the MarketId thing-y, I had time to dig into it and TBO it makes my head spinning a bit. The marketid inside the SerializableCart is different from the MarketId column in SerializableCart table. My initial thought is this is a bug. I will dig a little more and keep you updated.
Thank you for helping investigate this.
Do you know how the approach for this will be? Will you create a new migration step that will correct my issue as well - or should I proceede with a SQL script fix?
/Emil
Hi Emil,
We have already a migration step to migrate existing serializable carts when upgrading to Commerce 12.0.0. It's name is: "Migrates existing serializable carts." and it'll update the MarketId for the existing serializable carts. It seems to me that there were something wrong with this step.
Did it executed successfully? Or were there any error in the progress message when doing the migration? It'll help us to identify the problem quicker.
Thanks!
Hi Bien,
We have the "auto migrate setting" on, if I go to the episerver/commerce/migrate it's checked as done in the list.
The application is hosted on your DXC service. I pulled the logs from the time of the upgrade and there is two different errors
EPiServer.Framework.Initialization.InitializationEngine : Initialize action failed for 'Initialize on class EPiServer.Initialization.Internal.ModelSyncInitialization, EPiServer, Version=11.7.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
And many of this
EPiServer.DataAccess.Internal.JsonPropertyValueConverter : An exception occurred while converting JSON property
@Quan this is done on our production environment
/Emil
Thanks for your information. There were problems when upgrading obviously and that made the migration step stop working. So existing serializable carts were not migrated (correctly) logically.
However with the given logs, it's hard to know exactly where is the root cause. In this case, as Quan said, we would suggest you to contact our developer support service, so we can dig into it deeper.
/Bien
Hi!
We've upgraded to EPiServer commerce 12.2.0, now when we're trying to browse the carts we receive this error.
Any thoughts?
Best,
Emil