Issue with VariationContent after upgrading from EPiServer.Commerce 8.16.1 to 9.24.1

Member since: 2011

Hi,

After upgrading from EPiServer.Commerce 8.16.1 to 9.24.1 I have problems related to VariationContent which results in the following error "value is a System.Double but should be a System.Int32 Parameter name: value"

From the stack trace I can see that the error occurs in Mediachase.MetaDataPlus.Configurator.MetaDataTypes.GetDatabaseValueInteger(Object value) from EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.GenerateFields(CatalogContentBase content, Int32 objectId, MetaClass metaClass, MetaDataContext context)
 

Unfortunately it doesnt say anyting about which field/property causing this or the value of the field/property. 

Seems this has been improved in version 10 (http://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=COM-4607) but doesnt help me now.

I follow the plan by starting with upgrading from version 8 to 9 making this work before continuing to version 10 and onwards to 11.

http://world.episerver.com/documentation/upgrading/episerver-commerce/9/ 

http://vimvq1987.com/2016/04/upgrade-website-commerce-9/

 

First time I encountered this issue was in the migration step "Migrates most used draft: ready to publish, checked in, checked out and rejected draft.." when doing "Migrating 'CheckedOut' drafts".

To continue the migration steps I added DisableVersionSync = true. 

Afterwards going to Episerver CMS Admin and running "Draft store migration job" (DisableVersionSync = false) resulted in the same error:

Exception: System.ArgumentException

Message: value is a System.Double but should be a System.Int32
Parameter name: value

StackTrace:    at Mediachase.MetaDataPlus.Configurator.MetaDataTypes.GetDatabaseValueInteger(Object value)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.GenerateFields(CatalogContentBase content, Int32 objectId, MetaClass metaClass, MetaDataContext context)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.UpdateContentVersion(IList`1 contents, DataTable workIdMapping, Boolean publishAction)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.ImportVersion(IList`1 contents, IList`1 commonDraftWorkIds)
   at EPiServer.Commerce.Internal.Migration.DraftStoreMigrator.Migrate(VersionStatus status, Int32& total)
   at EPiServer.Commerce.Internal.Migration.ScheduledJobs.DraftStoreMigrationJob.DoMigrate(Object stateInfo)

I see the same error when trying to open an existing "product variant" in Commerce catalog or when creating a new one when pressing publish.

ArgumentException: value is a System.Double but should be a System.Int32
 Parameter name: value
Mediachase.MetaDataPlus.Configurator.MetaDataTypes.GetDatabaseValueInteger(Object value)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.GenerateFields(CatalogContentBase content, Int32 objectId, MetaClass metaClass, MetaDataContext context)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.UpdateContentVersion(IList`1 contents, DataTable workIdMapping, Boolean publishAction)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.CreateContentVersion(CatalogContentBase content, String currentUser, Boolean publishAction, Boolean skipSetCommonDraft)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.EnsureVersionLanguages(IList`1 versionList, ContentReference contentLink)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.List(ContentReference contentLink)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.List(ContentReference contentLink, String languageBranch)
EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.LoadCommonDraft(ContentReference contentLink, String language)
EPiServer.Cms.Shell.UI.Rest.CmsContentContextResolver.GetCommonDraft(ContentReference contentReference, String language, ContentLanguageInformation& languageInformation)
EPiServer.Cms.Shell.UI.Rest.CmsContentContextResolver.TryResolveUri(Uri uri, ClientContextBase& instance)
EPiServer.Shell.UI.Rest.ContextStore.ResolveUri(Uri uri)lambda_method(Closure , ControllerBase , Object[] )

I have also tried creating a new "product variant" inheriting from EPiServer.Commerce.Catalog.ContentTypes.VariationContent but no other properties.

[CatalogContentType(GUID = "D8B8A6EB-1DBB-47FE-9C9C-E3D9312AACC9", MetaClassName = "VariationTestClass")]
    [AvailableContentTypes(Availability = Availability.None)]
    public class ProductVariantTest : EPiServer.Commerce.Catalog.ContentTypes.VariationContent
    {
    }

Samme issue. Not being able to publish the "product variant" as it results in an error "value is a System.Double but should be a System.Int32 Parameter name: value"

Any ideas what causing this or any recommendations going forward?

//packages

<package id="EPiServer.CMS" version="9.12.2" targetFramework="net452" />
<package id="EPiServer.CMS.Core" version="9.12.4" targetFramework="net452" />
<package id="EPiServer.CMS.UI" version="9.9.2" targetFramework="net452" />
<package id="EPiServer.CMS.UI.Core" version="9.9.2" targetFramework="net452" />
<package id="EPiServer.Commerce" version="9.24.1" targetFramework="net452" />
<package id="EPiServer.Commerce.Core" version="9.24.1" targetFramework="net452" />
<package id="EPiServer.Commerce.FindSearchProvider" version="8.13.2" targetFramework="net452" />
<package id="EPiServer.Commerce.UI" version="9.24.1" targetFramework="net452" />
<package id="EPiServer.Commerce.UI.ManagerIntegration" version="9.24.1" targetFramework="net452" />
<package id="EPiServer.Find" version="12.0.0.4448" targetFramework="net452" />
<package id="EPiServer.Find.Cms" version="12.0.0.4448" targetFramework="net452" />
<package id="EPiServer.Find.Framework" version="12.0.0.4448" targetFramework="net452" />
<package id="EPiServer.Framework" version="9.12.4" targetFramework="net452" />

#181107 Aug 09, 2017 9:28
  • Member since: 2011

    This error is from a metafield which should be Int32, but has a value of double. I would suggest you to upgrade to 10.7.1 or later on another site, to see which metafield and which value caused the trouble, and fix that in your site.

    #181109 Aug 09, 2017 9:40
  • Member since: 2011

    Thanks Quan Mai, I'll try that.

    #181110 Aug 09, 2017 9:49
  • Member since: 2011

    Upgrading to Commerce 10 seems to solve the problem.

    Did the upgrade to 10.8.0 and went back to a copy of the DB from 8.16.1 so I could go through the migration steps related to 9 again. All steps succeeded incl. "Migrates most used draft: ready to publish, checked in, checked out and rejected draft.. -> Migrating 'CheckedOut' drafts" which failed before.

    #181136 Edited, Aug 09, 2017 14:10
  • Member since: 2011

    Hi again Quan,

    I was a little bit too quick marking this as solved. Even though I didn't get the error "value is a System.Double but should be a System.Int32" when doing the migration step "Migrates most used draft: ready to publish, checked in, checked out and rejected draft.. -> Migrating 'CheckedOut' drafts" as before or opening VariationContent in Commerce catalog or when publishing newly created VariationContent I still get a similar error message when running the scheduled job "Draft store migration job". I'll guess this is when migrating "previous versions" stored in DDS to the new catalog versioning system.

    Error in Commerce 10.8.0 when running "Draft store migration job":

    Message: Value of Weight is 0.007, of type System.Double, but should be an System.Int32
    Parameter name: value
    
    StackTrace:    at Mediachase.MetaDataPlus.Configurator.MetaDataTypes.GetDatabaseValueInteger(Object value, String metaFieldName)
       at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.GenerateFields(CatalogContentBase content, Int32 objectId, MetaClass metaClass, MetaDataContext context)
       at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.UpdateContentVersion(IList`1 contents, DataTable workIdMapping, Boolean publishAction)
       at EPiServer.Commerce.Catalog.Provider.CatalogContentVersionStore.ImportVersion(IList`1 contents, IList`1 commonDraftWorkIds)
       at EPiServer.Commerce.Internal.Migration.DraftStoreMigrator.Migrate(VersionStatus status, Int32& total)
       at EPiServer.Commerce.Internal.Migration.ScheduledJobs.DraftStoreMigrationJob.DoMigrate(Object stateInfo)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()

    What I dont understand here is why it says it should be an System.Int32. 

    Checking EPiServer.Commerce.Catalog.ContentTypes.VariationContent.Weight it is a double. The same for every version from 7.5 (site originally build on 7.5)  to 10 

    https://world.episerver.com/documentation/Class-library/?documentId=commerce/7.5/8D26F8F9

    https://world.episerver.com/documentation/Class-library/?documentId=commerce/8/8D26F8F9

    https://world.episerver.com/documentation/Class-library/?documentId=commerce/9/8D26F8F9

    https://world.episerver.com/documentation/Class-library/?documentId=commerce/10/8D26F8F9

    I rechon I properly needs to go look in the db tables. Could you point me in the correct direction? :)

    #181169 Aug 10, 2017 13:39
  • Member since: 2011

    I think that one of your metafields has the same name (Weight), and it is of type Int ...

    #181171 Aug 10, 2017 14:19
  • Member since: 2011

    Thats correct.  Querying the Commerce 8 database of the site or the Commerce 10 database of the upgraded site I get the following results.

    SELECT * FROM [dbCommerceManager].[dbo].[MetaField] where Name = 'Weight' 

    MetaFieldId Name Namespace SystemMetaClassId FriendlyName Description DataTypeId Length AllowNulls MultiLanguageValue AllowSearch Tag IsEncrypted IsKeyField

    194 Weight Mediachase.Commerce.Catalog 0 Weight NULL 26 4 1 0 0 NULL 0 0

    SELECT * FROM [dbCommerceManager].[dbo].[MetaDataType] where DataTypeId = 26

    DataTypeId Name FriendlyName Description Length SqlName AllowNulls Variable IsSQLCommonType DefaultValue

    26 Integer Integer Meta Data Type 4 int 1 0 0 0

    But the MetaField with id 194 doesn't belong to any MetaClass as this query returns 0 results:

    SELECT * FROM [dbCommerceManager].[dbo].[MetaClassMetaFieldRelation] where MetaFieldId = 194

    However when checking the table ecfVersionProperty which is a new table in the Commerce 10 upgraded site. Breaking change in Commerce 9.

    SELECT * FROM [dbCommerceManager].[dbo].[ecfVersionProperty] where MetaFieldId = 194

    pkId WorkId ObjectId ObjectTypeId MetaFieldId MetaClassId MetaFieldName LanguageName Boolean Number FloatNumber Money Date Binary String LongString Guid Decimal

    156 22 40221 0 194 29 Weight no NULL 4500 NULL NULL NULL NULL NULL NULL NULL NULL
    451 28 2032 0 194 29 Weight no NULL 1000 NULL NULL NULL NULL NULL NULL NULL NULL
    ....

    ....

    All the successfully migrated ones. So the "Weight" MetaField with ID 194 belong to MetaClassId 29.

    SELECT * FROM [dbCommerceManager].[dbo].[MetaClass] where MetaClassId = 29

    MetaClassId Namespace Name FriendlyName IsSystem IsAbstract ParentClassId TableName PrimaryKeyName Description FieldListChangedSqlScript Tag

    29 Mediachase.Commerce.Catalog.User VariationClass VariationClass 0 0 2 CatalogEntryEx_VariationClass PK_CatalogEntryEx_VariationClass NULL NULL

    My problem is where do I find the data "Value of Weight is 0.007". As it properly is a "previous published" content version of the "VariationClass" it should be located in the DDS tables tblBigTable.

    From page 58 in your book "Pro Episerver Commerce" data should be located in CatalogContentDraftStore. Serialized and stored in a big column of type nvarchar(MAX):

    " Each version (which was call CatalogContentDraft) is stored in one row, and except the “static” data which is supposed to be on all version (such as content link, code, etc), all properties (aka IContent.Property) are serialized and stored in a big column of NVARCHAR(MAX)."

    The columns of type nvarchar(MAX) in tblBigTable are named "String01" to "String10" but doesn't seem to be serialized data.

    #181173 Edited, Aug 10, 2017 15:53
  • Member since: 2011

    Which database were you talking about? Because in Commerce 9 after migration all CatalogContentDraft will be deleted 

    #181198 Aug 11, 2017 17:46
  • Member since: 2011

    Yes but my problem is that I'm not able to migrate previous published versions to new versioning system using the scheduled job "Draft store migration job"

    As im upgrading from Commerce 8 the previous published versions are stored in DDS. Store "EPiServer.Commerce.Catalog.Provider.CatalogContentDraft". Data stored in tblBigTable.

    I started upgrading from 8 -> 9 and running scheduled job "Draft store migration job" in Commerce 9 resulted in error "value is a System.Double but should be a System.Int32 Parameter name: value". Not to much use.

    You recommended me to upgrade to Commerce 10. Running the scheduled job "Draft store migration job" here results in the error "Value of Weight is 0.007, of type System.Double, but should be an System.Int32". A little bit better error message but would have been nice if the error message had the content id included. 

    My problem now is finding out which previous published version of CatalogContentBase (content id) stored in DDS Store = CatalogContentDraft that have a "weight" property with the value of "0.007".

    #181229 Aug 14, 2017 15:20
  • Member since: 2011

    I have no Commerce 8 database to look at right now, but that's trange. How many rows do you have if you select from that table with StoreName like '%CatalogContentDraftStore%'?

    #181230 Aug 14, 2017 15:31
  • Member since: 2011

    40757 rows.

    I'm able to get all items in the store using this code:

    DynamicDataStore draftStore = typeof(CatalogContentDraft).GetStore();
                var items = draftStore.Items<CatalogContentDraft>();

    But when I use GetContent() method on CatalogContentDraft it throws a NullReferenceException

    #181231 Aug 14, 2017 15:40
First   1 2   Last