In the previous article, we did learn about the process of Sitecore authentication which uses the ASP.NET membership behind the scene. We also discussed how the user profile data are stored in the database and how we can extract and de-serialize the same.
The following are the previous two articles for your reference.
- Sitecore Commerce to Order Cloud Data Migration – Article 1
- Sitecore Commerce to Order Cloud Data Migration – Article 2 – Users migration
In this article, we will continue our journey of users migration and touch base for the commerce customer entity data extraction.
Sitecore commerce stores the customer data int he following tables. The Sitecore Commerce Business Tools uses these tables to show the customer data. These tables are available in the both GlobalEnvironments and SharedEnvironments. I used the tables from the SharedEnvironments database.
For the purpose of customer entity data extraction, we need to query the [sitecore_commerce_storage].[CustomersEntity] table. This table contains the UniqueId column, which relates the table with another table [sitecore_commerce_storage].[CustomersEntities].
This, [sitecore_commerce_storage].[CustomersEntities], table contains the Id columns which stores the CustomerId value. This CustomerId value is used across the Sitecore Commerce Business Tools to refer and load the customer’s data associated through this Id.
If you see the following JSON, which I explained in my previous article, it contains the Customers array or ExternalId attribute.
For my data export purpose, I used the ExternalId value to query the [sitecore_commerce_storage].[CustomersEntity] table. The following is the C# code which I implemented to query the customer entity data.
This is regarding the customer entity data which you can query, process, and export along with the ASP.NET Membership user data.
Now, there is another way around to query the customer data as well but that will not give you the information about the user’s last login data based on which you should query the time bound set of users to migrate. However, if you need to migrate all the users then you can use the Solr to query the Customer entity data first.
YES!. Sitecore Commerce Solr cores store the necessary information which you can use to query the user profile as well as the Customer Entity data in the database.
The Solr core, CustomersScope, stores all the necessary information which we need. As shown in the below screenshot, we can use Email attribute or username attribute to query the ASP.NET Membership tables to get user profile data, and the entityid attribute to query the Customer Entity from the Commerce database.
I hope you find this article worthy to refer for your Sitecore Commerce to OrderCloud migration.
In the next article, we will go through the process of extracting the Orders data from the Sitecore Commerce database.