Sitecore Commerce and Solr -- How to Integrate Apache Solr with Sitecore Commerce 9.1 using SearchStax


Overview

SearchStax® can be used to enable Apache Solr on a Sitecore Commerce website.

Sitecore Commerce using SearchStax must be installed on top of an already existing Sitecore (XP) installation. Please see our guide on installing Sitecore 9.1.

Contents:

  1. Download and Prep
  2. Prepare the Install Script
  3. Install Sitecore Commerce
  4. Configure Solr
  5. Configure Sitecore Commerce

Download and Prep

Sitecore Commerce requires that the following packages to be downloaded and extracted before starting the installation:

Sitecore Commerce 9.1

Download the following package:

Package Name URL
Packages for On Premise 2019.04-3.0.163 https://dev.sitecore.net/Downloads/Sitecore_Commerce/91/Sitecore_Experience_Commerce_91_Initial_Release.aspx
  1. Create a C:\deploy directory.
  2. Extract the contents of the downloaded package into C:\deploy.
  3. Navigate to C:\deploy, and extract the following packages:
    1. SIF.Sitecore.Commerce.x.x.xxxx.zip
    2. Sitecore.Commerce.Engine.x.x.xxxx.zip
    3. Sitecore.Commerce.Engine.SDK.x.x.xxxx.zip
    4. Sitecore.BizFX.x.x.xxx.zip
  4. Make a note of the file Sitecore.Commerce.Engine.DB.dacpac location. (Usually it will be at C:\deploy\Sitecore.Commerce.Engine.SDK.3.0.40\Sitecore.Commerce.Engine.DB.dacpac).

Sitecore PowerShell Extension 4.7 or 5.0

Download the following package:

Package Name URL
Full 5.0 Release https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/18/Sitecore_Experience_Accelerator_181.aspx

Copy the downloaded content into C:\deploy.

Sitecore Experience Accelerator 1.8-1

Download the following package:

Package Name URL
Sitecore Experience Accelerator for 9.1.1 https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/18/Sitecore_Experience_Accelerator_181.aspx

Copy the downloaded content into C:\deploy.

MSBuild Microsoft Visual Studio Web targets

Download the following package:

Package Name URL
Full 5.0 Release https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/18/Sitecore_Experience_Accelerator_181.aspx
  1. Create a new blank project in Visual Studio.

    1. Create a new project, ASP.NET Web Application (.NET Framework) C#
      SearchStax Sitecore Commerce
    2. Select Empty project, and then check the box for MVC, click create.
      SearchStax Sitecore Commerce

  2. Tools > NuGet Package Manager > Package Manager Console

  3. Execute the following command:
    Install-Package MSBuild.Microsoft.VisualStudio.Web.targets -Version 14.0.0.3
  4. Open File Explorer and navigate to the root directory of the blank project.
  5. Navigate to packages.
  6. Copy the folder MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3.
  7. Paste it to C:\deploy.
  8. Make a note of the location of Microsoft.Web.XmlTransform.dll. Usually it will be at C:\deploy\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath\Web\Microsoft.Web.XmlTransform.dll.

Prepare the Install Script

The script is located at c:\deploy\SIF.Sitecore.Commercec.x.x.xxx\Deploy-Sitecore-Commerce.ps1.

Create a copy of the script and name it "MyDeploy-Sitecore-Commerce.ps1".

If you are installing this on an On-Premise Sitecore installation, then you must have specified a Prefix when installing Sitecore XP 9.1. If yes, then make the following changes:

Variable Value
[string]$Prefix "sitecore" (enter your prefix here)
[string]$SiteName "$Prefix.sc"
[string]$SqlDbPrefix "$Prefix"
[string]$IdentityServerSiteName "$Prefix.identityserver"
XConnectInstallDir "c:\inetpub\wwwroot\$Prefix.xconnect"

Comment out or remove these variables for Solr:

# SolrRoot                                    = "c:\\solr-7.2.1"
# SolrService                                 = "solr-7.2.1"

You must also set the following variables and values:

Variable Value
CommerceEngineDacPac Resolve-Path -Path "C:\deploy\Sitecore.Commerce.Engine.SDK.3.0.40\Sitecore.Commerce.Engine.DB.dacpac" (Value noted in the steps above)
SitecoreCommerceEnginePath Resolve-Path -Path "..\Sitecore.Commerce.Engine.3.0.163.zip"
SitecoreBizFxServicesContentPath Resolve-Path -Path "..\Sitecore.BizFX.2.0.3.zip"
PowerShellExtensionsModuleFullPath Resolve-Path -Path "..\Sitecore PowerShell Extensions*.zip"
SXAModuleFullPath Resolve-Path -Path "..\Sitecore Experience Accelerator*.zip"
SXACommerceModuleFullPath Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator 2.*.zip"
SXAStorefrontModuleFullPath Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Storefront 2.*.zip"

Note

Since we are not using a local instance of Solr, we will disable installation of cores while Sitecore is being installed.

Disable Solr Core installation by updating the install command in the script to the following:

Install-SitecoreConfiguration @params -Skip InstallSolrCores -Verbose *>&1 | Tee-Object "$PSScriptRoot\XC-Install.log"

If you changed the default Sitecore password, please follow the instructions here to make sure the Sitecore Commerce installer is changed accordingly: http://commercesdn.sitecore.net/SitecoreXC_9.1/Sitecore_XC-9.1_Installation_Guide_for_On-Prem.pdf

Install Sitecore Commerce

  1. Open PowerShell v5 as an administrator.

  2. Navigate to C:\deploy\SIF.Sitecore.Commerce.2.0.19.

  3. Set the execution policy to bypass:
    Set-ExecutionPolicy Bypass

  4. Execute the script:
    .\MyDeploy-Sitecore-Commerce.ps1

Configure Solr

Along with the collections that Sitecore XP uses by default, Sitecore Commerce expects Solr to have additional collections, each with an appropriate config directory.

Create Configs

  1. Use either the SearchStax API, or the SearchStax Client (zkcli) to upload/download the configs from Zookeeper.
  2. Download the existing _default config from Zookeeper.
  3. Create three copies of the _default directory and name them:
    • CatalogItems
    • Customers
    • Orders
  4. Navigate to c:\deploy\SIF.Sitecore.Commercec.x.x.xxx\SolrSchemas.
  5. Copy the content of the CatalogItems folder to the copy of the _default directory created above.
  6. Copy the content of the Customers folder to the copy of the _default directory created above.
  7. Copy the content of the Orders folder to the copy of the _default directory created above.
  8. Upload CatalogItems, Customers, and Orders config directories to Zookeeper with the same name.
  9. Upload the Sitecore default config as sitecore_default.

Create Collections

Create the following collections with the respective configs:

Collection Name Config
sitecore_sxa_master_index sitecore_default
sitecore_sxa_web_index sitecore_default
CatalogItemsScope CatalogItems
CustomersScope Customers
OrdersScope Orders

Configure Sitecore Commerce

Setting Up Config Files

Sitecore will mostly communicate to Solr via the settings of Sitecore XP.

Other than that, the following files will need to be updated as well:

How to Update the Files:

  1. Open to the desired file in an editor as an administrator.
  2. Set the following parameters:
    "IsSolrCloud" : "true" "SolrUrl" : "<loadbalancerUrl>/solr"

Bootstrap Sitecore Commerce

  1. Follow the instructions here to download and set up a Postman project that can interact with Sitecore Commerce and help perform Ops tasks: https://doc.sitecore.com/developers/91/sitecore-experience-commerce/en/execute-sample-api-calls-in-postman.html
  2. After successfully setting up the Postman project, use the following instructions to Bootstrap Commerce Engine: https://doc.sitecore.com/developers/91/sitecore-experience-commerce/en/bootstrap-the-commerce-engine.html
  3. After a successful bootstrap, use the following instructions to clean and initialize the environment: https://doc.sitecore.com/developers/91/sitecore-experience-commerce/en/clean-and-initialize-the-environment.html