How to Integrate Apache Solr with Sitecore Commerce 9.1 using SearchStax Cloud


Overview

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

Sitecore Commerce using SearchStax Cloud 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
  • Sitecore PowerShell Extension 4.7 or 5.0
  • Sitecore Experience Accelerator 1.8-1
  • MSBuild Microsoft Visual Studio Web targets

Sitecore Commerce 9.1

Download the following package:

Package NameURL
Packages for On Premise 2019.04-3.0.163https://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:
    • SIF.Sitecore.Commerce.x.x.xxxx.zip
    • Sitecore.Commerce.Engine.x.x.xxxx.zip
    • Sitecore.Commerce.Engine.SDK.x.x.xxxx.zip
    • 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:deploySitecore.Commerce.Engine.SDK.3.0.40Sitecore.Commerce.Engine.DB.dacpac).

Sitecore PowerShell Extension 4.7 or 5.0

Download the following package:

Package NameURL
Full 5.0 Releasehttps://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 NameURL
Sitecore Experience Accelerator for 9.1.1https://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

  1. Create a new blank project in Visual Studio.
    • Create a new project, ASP.NET Web Application (.NET Framework) C#
SearchStax Sitecore Commerce
  1. Select Empty project, and then check the box for MVC, click create.
SearchStax Sitecore Commerce
  1. Tools > NuGet Package Manager > Package Manager Console
  2. Execute the following command:
    Install-Package MSBuild.Microsoft.VisualStudio.Web.targets -Version 14.0.0.3
  3. Open File Explorer and navigate to the root directory of the blank project.
  4. Navigate to packages.
  5. Copy the folder MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3.
  6. Paste it to C:deploy.
  7. Make a note of the location of Microsoft.Web.XmlTransform.dll. Usually it will be at C:deployMSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3toolsVSToolsPathWebMicrosoft.Web.XmlTransform.dll.

Prepare the Install Script

The script is located at c:deploySIF.Sitecore.Commercec.x.x.xxxDeploy-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:

VariableValue
[string]$Prefix"sitecore" (enter your prefix here)
[string]$SiteName"$Prefix.sc"
[string]$SqlDbPrefix"$Prefix"
[string]$IdentityServerSiteName"$Prefix.identityserver"
XConnectInstallDir"c:inetpubwwwroot$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:

VariableValue
CommerceEngineDacPacResolve-Path -Path "C:deploySitecore.Commerce.Engine.SDK.3.0.40Sitecore.Commerce.Engine.DB.dacpac" (Value noted in the steps above)
SitecoreCommerceEnginePathResolve-Path -Path "..Sitecore.Commerce.Engine.3.0.163.zip"
SitecoreBizFxServicesContentPathResolve-Path -Path "..Sitecore.BizFX.2.0.3.zip"
PowerShellExtensionsModuleFullPathResolve-Path -Path "..Sitecore PowerShell Extensions*.zip"
SXAModuleFullPathResolve-Path -Path "..Sitecore Experience Accelerator*.zip"
SXACommerceModuleFullPathResolve-Path -Path "..Sitecore Commerce Experience Accelerator 2.*.zip"
SXAStorefrontModuleFullPathResolve-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 "$PSScriptRootXC-Install.log"

If you changed the default Sitecore password, please follow the instructions here to make sure the Sitecore Commerce installer is changed accordingly.

Install Sitecore Commerce

  1. Open PowerShell v5 as an administrator.
  2. Navigate to C:deploySIF.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 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:deploySIF.Sitecore.Commercec.x.x.xxxSolrSchemas.
  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 NameConfig
sitecore_sxa_master_indexsitecore_default
sitecore_sxa_web_indexsitecore_default
CatalogItemsScopeCatalogItems
CustomersScopeCustomers
OrdersScopeOrders

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:

  • C:inetpubwwwrootCommerceAuthoring_Sc9wwwrootdataEnvironmentsPlugIn.Search.Solr.PolicySet-1.0.0.json
  • C:inetpubwwwrootCommerceMinions_Sc9wwwrootdataEnvironmentsPlugIn.Search.Solr.PolicySet-1.0.0.json
  • C:inetpubwwwrootCommerceOps_Sc9wwwrootdataEnvironmentsPlugIn.Search.Solr.PolicySet-1.0.0.json
  • C:inetpubwwwrootCommerceShops_Sc9wwwrootdataEnvironmentsPlugIn.Search.Solr.PolicySet-1.0.0.json

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/xp/en/developers/92/sitecore-experience-commerce/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/xp/en/developers/92/sitecore-experience-commerce/bootstrap-the-commerce-engine.html
  3. After a successful bootstrap, use the following instructions to clean and initialize the environment: https://doc.sitecore.com/xp/en/developers/91/sitecore-experience-commerce/clean-and-initialize-the-environment.html

Questions?

Do not hesitate to contact the SearchStax Support Desk.