Sitecore Commerce Engine Debugging

Image

I wanted to debug Sitecore Commerce Engine in Visual Studio and there are lot of posts showing how to make your life easy with Sitecore XC debugging. The best one that I liked is Setup Visual Studio Environment for Commerce Engine Custom Plug-in Development and Debugging as it gives you the precise information step-by-step for debugging.My intent here is to share some tips or gotchas which someone should pay extensive attention to get going with Sitecore Commerce Engine debugging.Problem that I ran into was Sitecore Commerce Engine was not getting started and was stucked at [EnvironmentStartup] StartEnvironment=HabitatMinions

Sitecore commerce minions HabitatMinions

It was stopping at this point because in Startup.cs file it went into a wait mode,

Wait

Nothing was wrong with this code as refactoring Sitecore.Commerce.Engine.exe that was deployed in Authoring role also had same code and it is working there. Hence it has to be related something to configuration so I started looking at config.json that came with the SDK Solution.First difference I found was with   "EnvironmentName": "HabitatMinions" but my Authoring role was named as HabitatAuthoring. Hoever this was not a problemMy second attention was drawn to the Allowed Origins List where my store front url was mycommerce.storefront.local which was different as compared to \Sitecore.Commerce.Engine.SDK.2.1.10\src\Sitecore.Commerce.Engine\wwwroot\config.json file which had sxa.storefront.com. Again, this was not a problem.Also, I made sure the thumbprint is matching what was generatedNext step was to start looking at Sitecore.Commerce.Engine.SDK.2.1.10\src\Sitecore.Commerce.Engine\wwwroot\bootstrap\Global.json file and make sure the SQL details were correct and yes, they were perfectly fine.Lastly, I realized the Database Name is not correct in the Global.json file as during Sitecore Commerce Installation we changed the names for the databases. That was the root cause of all my troubles huh!. As the sample solution Global.json comes with a default Sitecore Commerce Database name as Database: SitecoreCommerce_Global.

EntityStoreSqlPolicy

Password and UserName are not required to be updated in the json file.Make sure the Server is specified correctly.There are two sections in Global.json that refers to SQL details,

  1. "$type": "Sitecore.Commerce.Plugin.SQL.EntityStoreSqlPolicy, Sitecore.Commerce.Plugin.SQL"
  2. "$type": "Plugin.Sample.Upgrade.MigrationSqlPolicy, Plugin.Sample.Upgrade"

Make sure you provide correct values of SQL to #1 section mentioned above.#2 section values will not matter unless you are using the upgrade plugin sample that comes with the SDK solution.Finally if the above gotchas still do not work for you, the Brahmastra is to copy \CommerceAuthoring_Sc9\wwwroot\config.json and \CommerceAuthoring_Sc9\wwwroot\global.json from Authoring role and add them to the sample solution and debug Sitecore Commerce Engine. This works like a charm!