Assurex's Sandeep and Saurabh are recognised as Sitecore Most Valueable Professionals Find out more         
Commerce Engine Development
Commerce Development Get It Right Sitecore Tips & Tricks

Setup development environment for Sitecore Commerce 9.3 Engine

As we have discussed in other blogs, Sitecore Commerce is built for extension. It allows you to build and add features by creating plugins.

In this post, I am going to describe how to set up your Sitecore Commerce development environment and start using Commerce Engine SDK for development. If you want to run “Business Tools”/Storefront using SDK, don’t miss the steps highlighted in ‘RED’ towards the end of this blog.

In the next topic in this series, I will explain how to create a new plugin for Sitecore Commerce.

This post assumes that you have already downloaded Sitecore Commerce 9.3 initial release and installed it as per the instructions here

I am using Visual Studio, 2019.

With further ado, let’s get to the steps to set up the SDK.

Step 1- Extract Commerce Engine SDK

Sitecore Commerce installation package comes with Sitecore Commerce Engine SDK.

  1. Copy the downloaded SDK Sitecore.Commerce.Engine.SDK.5.0.76.zip on your development folder. If needed, you can download the same here
  2. Extract Sitecore.Commerce.Engine.SDK.5.0.76.zip, the output will look like this –

Step 2 – Setup Visual Studio Solution

  1. From the extracted folder open ‘Customer.Sample.Solution.sln’ solution.
  2. Configure NuGet package to https://sitecore.myget.org/F/sc-commerce-packages/api/v3/index.json
  3. Build the Solution. It should restore the package and build successfully.
    Steps below are recommended for proper development setup, you can skip these steps in case you are just playing around –
  4. (optional)Rename the Solution. In this case, I have renamed to Retail. Commerce
  5. (Optional) Create a solution folder “Project” and move Sitecore.Commerce.Engine project
  6. (Optional) Rename “Sitecore.Commerce.Engine” project to “Retail.Commerce.Engine”. Re reference AdventureWorks, Habitat and BrainTree projects if required. Adjust/rename namespace in classes.
  7. (Optional) Create Foundation and Feature projects. Build the solution again.

Step 3 – Generate Development Certificate

Generate development certificate using the following script –
“New-DevelopmentCertificate”, so the localhost runs on SSL(https) 

  1. Open PowerShell console as an admin and navigate to the scripts folder.
  2. Execute New-DevelopmentCertificate script
  3. Change the Path($certificateOutputDirectory) if required. Certificate should be copied to \src\Project\Engine\code\wwwroot

Step 4 – Update configuration

  1. Change the “environment” in Engine project/wwwroot/config.json file to HabitatAuthoring
  2. Change “SitecoreIdentityServerUrl”: “https://storefront930.identityserver.local”
  3. Add/Update the site(storefront) name (e.g.:-http://sxa.storefront.com) in AllowedOrigins in config.json
  4. Add/Update business tool url to Allowed Origin e.g.:- https://bizfx.sc910.qa
  5. Open Global.json in  wwwroot/bootstrap folder in Engine project
    The steps above will allow you to use the installed identity server to server request from IIS.
  6. Update SQL Server, UserName and Password in EntityStoreSqlPolicy
  7. Check the database name

    7. Update Host to your site hostname in SitecoreConnectionPolicy

Note: You may copy the config.json and gloal.json file from Authoring Site hosted in IIS to your project, but to better understand the changes required I have noted the changes. 

Step 5 – Update allowed origins in Identity Site

  1. Open Sitecore.Commerce.IdentityServer.Host.xml file. Should be in <identityserversite>/config/production/Sitecore.Commerce.IdentityServer.Host.xml
  2. Navigate to section <CommerceEngineConnectClient> <AllowedCorsOrigins>
  3. Add https://localhost:5000 to the <AllowedCorsOriginsGroup1>

Step 6 – Ready for running the Engine

  1. Set Engine as your Startup Project
  2. Change the debug profile to “Engine” instead of “IIS Express”
  3. In IIS stop Authoring site. i.e. for your default instance, it might be CommerceAuthoring_sc930 site
  4. Run the Engine from Visual Studio. This will open the console.
  5. Once the plugins are instantiated, the solution should listen to 5000 port. At this point, you have configured Engine to run/debug from Visual Studio. Any calls from the business tool should be received by engine and console should be able to show the request that’s been received.

And here we have business tool sending the request to the commerce engine running on Visual Studio, see GetNavigationView() been called in the console

For Storefront to redirect calls to engine update shopsServiceUrl in Sitecore.Commerce.Engine.Connect.config file to https://localhost:5000/api/

This is a comprehensive list of steps needed to run the Sitecore Commerce engine SDK properly and you should be able to set up your environment without any issues.

In the next blog, we will set out instructions to create a new plugin.

If you come across anything that is not covered, please let us know in the comments.

Don’t forget to share and like this post on the channels below.

Assure your implementation and book a 30 mins consultation with one of our experts.

Did you find this useful? If so, please share with your connections.

Leave a Reply

Your email address will not be published. Required fields are marked *