[Sitecore XC 9.0.2]-Initialize a Commerce Engine without example Plugins; Bootstrap and Initialize new Environments

Since I want to start a completely new commerce engine project without any example plugin which come from Sitecore Commerce Engine SDK; then I can define my own environments which are DemoHomeAuthoring and DemoHomeShops. Moreover, I expect the whole process should take around 30 minutes and even automatically as much as possible (of course using PowerShell script). In this post, I’m going to tell what I tried to accomplish the task.

First, I’d thank for Sitecore Community for some blog posts (which will be listed at the end of this post) which guides us removing example plugins from Sitecore Commerce Engine SDK. Based on that, I can accomplish my own commerce engine project which is totally fresh and clean.

TL;DR: Here are the common steps

  • Start with Sitecore.Commerce.Engine.SDK.2.2.72.zip
  • Remove the referenced example projects (aka Plugins) from Sitecore.Commerce.Engine
    • Plugin.Sample.AdventureWorks
    • Plugin.Sample.Customers.Upgrade
    • Plugin.Sample.Habitat
    • Plugin.Sample.Payments.Braintree
    • Plugin.Sample.Upgrade
    • Plugin.Sample.Customers.CsMigration
  • Add the required packages from Sitecore Commerce Nuget repository
    • Sitecore.Commerce.Plugin.Coupons
    • Sitecore.Commerce.Plugin.Journaling
    • Sitecore.Commerce.Plugin.SQL
    • Sitecore.Commerce.Plugin.Tax
  • Define the set of configurations for our new Environments based on Habitat
    • Plugin.DemoHome.CommerceAuthoring-1.0.0.json
    • Plugin.DemoHome.CommerceMinions-1.0.0.json
    • Plugin.DemoHome.CommerceShops-1.0.0.json
  • Remove the policies’s configurations from  the set of configuration file above since we don’t use it at this time
  • Disable Habitat and AventureWorlds Plugins
  • Update PluginContent-PolicySet, Plugin-SearchSolr-Policy, Plugin-SQL-Policy
  • Update the config from BizFx and IdentityServer
  • Update Default Shop Name and Default Environment for Sitecore.Commerce.Engine.Connect 
  • Deploy, Bootstrap and Initialize (same the way of Sitecore.HabitatHome.Commerce does)

Before starting, let assumes that:

  • The instance of Sitecore Experience Platform 9.0.2 has been installed successfully at demohome.dev.local
  • The fresh instance of Sitecore Experience Commerce 9.0.2 has been installed successfully without pre-loaded demo assets (i.e. AdventureWorlds, Habitat)

Notes: please see this link if they’s not ready


Let starts with creating default Tenant and Site

Create Demo Sites tenant
  • Create a new site – Demo Home within Commerce Storefront Components module
Create Demo Home site

Initialize commerce engine project from Visual Studio

  • Let open Visual Studio and create a new solution – DemoHome
  • Extract the Sitecore.Commerce.2018.07-2.2.126.zip file
    • If you’ve already used Sitecore.HabitatHome.Utitlities, this file is located at XC\install\assets\Downloads
    • Or it can be downloaded directly from here
  • Next, find and extract Sitecore.Commerce.Engine.SDK.2.2.72.zip
  • Suppose that DemoHome solution is located at D:\Sitecore\DemoHome. We have to copy the following:
    • nuget.config from extracted folder to DemoHome solution folder.
    • Copy src\Sitecore.Commerce.Engine from extracted folder to DemoHome solution folder with the same structure.
  • Back to Visual Studio, include Sitecore.Commerce.Engine project into DemoHome solution
Include Sitecore.Commerce.Engine project into DemoHome solution

Start modifying commerce engine project

  • [IMPORTANT NOTE] : this step must be executed only ONE TIME at the beginning.
  • Download the initialize-sitecore-commerce-engine-project.ps1 script below and put it in the same place with DemoHome.sln. Open by any text editor, then update the values of $webRoot and $solrUrl
initialize-sitecore-commerce-engine-project.ps1
  • Open PowerShell as Administrator and execute the script

.\initialize-sitecore-commerce-engine-project.ps1

Deploy our commerce engine

  • Download the deploy-commerce-engine.ps1 script in below and put it in the same place with DemoHome.sln file. Open with any text editor, then update the value of $webRoot
deploy-commerce-engine.ps1
  • Still in PowerShell, execute the script

.\deploy-commerce-engine.ps1 -Bootstrap -Initialize

Notes: this script is from Sitecore.HabitatHome.Commerce but it has some modifications for my purpose.

Update Sitecore Commerce Connect configurations

  • Since the origin Sitecore.Commerce.Engine.Connect module was installed with default configurations for HabitatAuthoring and HabitatShops. Those configurations can be found at [IIS-webroot]\demohome.dev.local\App_Config\Include\Y.Commerce.Engine from the following files:
    • Sitecore.Commerce.Engine.Connect.config
    • Sitecore.Commerce.Engine.Connectors.Index.Common.config
    • Sitecore.Commerce.Engine.Connectors.Index.Solr.config
  • Therefore, we have to update to match with our expectation which are: DemoHomeAuthoring and DemoHomeShops. The simplest way is utilize Sitecore’s patch files; just download the below patch files and put it at [IIS-webroot]\demohome.dev.local\App_Config\Include\ZZ.Commerce.Engine
zDemoHome.Engine.Connect.config & zDemoHome.Engine.Connectors.Index.config

Finally, let verify our stuffs

Business Tool: https://localhost:4200

Resources

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s