Sitecore Commerce and Solr -- How to Integrate Apache Solr with Sitecore Commerce 9.2 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.2.

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:

Redis

Download the msi file and follow the prompts for installation.

Package Name URL
Redis on Windows 3.2 https://github.com/microsoftarchive/redis/releases

Sitecore Commerce 9.2

Download the following package:

Package Name URL
Packages for On-Premises2019.08-x.x.xxx https://dev.sitecore.net/Downloads/Sitecore_Commerce/92/Sitecore_Experience_Commerce_92_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

Sitecore PowerShell Extension 5.0 for Sitecore 9.2

Download the following package:

Package Name URL
Sitecore PowerShell Extension 5.0 for Sitecore 9.2 https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/19/Sitecore_Experience_Accelerator_190.aspx

Copy the downloaded content into C:\deploy.

Sitecore Experience Accelerator 1.9

Download the following package:

Package Name URL
Sitecore Experience Accelerator for 9.2 https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/19/Sitecore_Experience_Accelerator_190.aspx

Copy the downloaded content into C:\deploy.

MSBuild Microsoft Visual Studio Web targets

  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.Commerce.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.2. If yes, then make the following changes:

Variable Value
[string]$SiteNamePrefix "sitecore92" (enter your prefix here)
[string]$SqlUser "sa"
[string]$SqlPass password

Comment out or remove these variables for Solr:

# SolrRoot                                    = "c:\\solr-7.5.0"
# SolrService                                 = "solr-7.5.0"
# SolrSchemas

You must also set the following variables and values:

Variable Value
SolrUrl https://ss418450-kk4krf07-us-west-1-aws.searchstax.com/solr

Go to C:\deploy\SIF.Sitecore.Commerce.3.0.28\Configuration\Commerce\Solr\Solr.Install.json and change the value of Skip.Solr to True

"Skip.SOLR": "True"

Install Sitecore Commerce

  1. Open PowerShell v5 as an administrator.

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

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

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

  5. Manually remove the following folder: C:\inetpub\wwwroot\$Prefix.SC\SiteUtilityPages

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 the SearchStax Client (zkcli) to download the existing _default config from Zookeeper. ./zkcli.sh -zkhost <zookeeper ensemble> -cmd downconfig -confname _default -confdir ~/workspace/sitecoreXC92/conf/_default
  2. Create three copies of the _default directory and name them:
    • CECatalogItemIndex
    • CEOrderIndex
    • CECustomerIndex
  3. Copy the solrconfig.xml and managed-schema file available in the SolrSchemas folder of the SolrSchemas.Sitecore.Commerce.x.x.x zip file, included in the Sitecore XC release package:
    • Copy the SolrSchemas\CatalogItems\*.* files to the CECatalogItemIndex folder.
    • Copy the SolrSchemas\Customers\*.* files to the CECustomerIndex folder.
    • Copy the SolrSchemas\Orders\*.* files to the CEOrderIndex folder.
  4. Upload the 3 config folders to zookeeper:
    ./zkcli.sh -zkhost <zookeeper ensemble> -cmd upconfig -confname CECatalogItemIndex -confdir ~/workspace/sitecoreXC92/conf/CECatalogItemIndex ./zkcli.sh -zkhost <zookeeper ensemble> -cmd upconfig -confname CECustomerIndex -confdir ~/workspace/sitecoreXC92/conf/CECustomerIndex ./zkcli.sh -zkhost <zookeeper ensemble> -cmd upconfig -confname CEOrderIndex -confdir ~/workspace/sitecoreXC92/conf/CEOrderIndex

Create Collections

Create the following collections with the respective configs:

Collection Name Config
CatalogItemScope CECatalogItemIndex
CustomersScope CECustomerIndex
OrdersScope CEOrderIndex
sitecore_sxa_master_index config used for sitecore_web_index
sitecore_sxa_web_index config used for sitecore_master_index

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 each PlugIn.Search.Solr.PolicySet-1.0.0.json file.
  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/92/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/92/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/92/sitecore-experience-commerce/en/clean-and-initialize-the-environment.html