Tag: Sitecore XC

Install Sitecore Commerce 10.3 using SIF

Follow these steps to install Sitecore Commerce 10.3 On Premise. To successfully install refer to Installation Guide provided by Sitecore.

Before installing Sitecore Commerce install Sitecore XP 10.3. See this blog to install Sitecore XP 10.3 using SIF. Say the XP site name is- xp103.sc

Download Installation Guide

Hosting Environment Requirements/ Download and Install following software-

  1. OS – Windows Server 2019/2016 or Windows 10 Pro(64-bit) or Windows 11 Pro(64-bit)
  2. Redis (Windows): 3.0.504 (or later)
  3. Database – Microsoft SQL Server 2017 Express Edition (This should be already installed as a part of XP 10)
  4. Install Microsoft Web Deploy 3.6 if not already installed
  5. Install URL Rewrite using Web Platform Installer
  6. SOLR 8.11.2 (This should have already installed as a part of XP 10.3 install)
  7. Install PowerShell 5.1 or later is not already installed
  8. Web Platform Transformer (Download nuget package)
  9. (Important) Install Web hosting- here

IMPORTANT β€“ As per the release notes β€“

The deployment of SXA has been removed from the Commerce installation, and instead installed as a Platform pre-requisite before installing Commerce packages.

Sitecore PowerShell Extension for Sitecore on your local Sitecore instance if not already

Sitecore Experience Accelerator on your local Sitecore instance if not already

Also Commerce Ops service is removed from deployment configuration this will reduce deployment time and hosting cost.

Before starting the installation ensure XP 10.2 instance is working and indexed. If not indexed rebuild all search indexes-

Download Sitecore Experience Commerce 10.3

Step-by-step installation process-

1. Create a installation folder for XC – xcinstall for e.g.- C:\SCInstallation\103\xc103

2. Copy and extract Sitecore.Commerce.WDP.2022.12-9.0.82.zip file to C:\SCInstallation\103\xc103

3. Extract Web Platform Transfomer nuget package and copy Microsoft.Web.XmlTransform.dll to C:\SCInstallation\103\xc103

4. Extract SIF.Sitecore.Commerce.8.0.14.zip to C:\SCInstallation\103\xc103 folder. Rename this to SIF

Installation folder structure should look like this-

 Open Deploy-Sitecore-Commerce.ps1 file in SIF folder to update the following-

  • $XCInstallRoot
  • $XCSIFInstallRoot = β€œ$XCInstallRoot\SIF” or $PWD is fine – it is Present Working Directory,
  • $SiteNamePrefix
  • $SiteName
  • $SiteHostHeaderName [optional]
  • $MergeToolFullPath= β€œ$XCInstallRoot\Microsoft.Web.XmlTransform.dll”
  • $CommerceServicesDbServer = β€œβ€

12. Create Commerce Engine Connect Client Secret for the Sitecore Identity Server

  • Copy below script to file to scinstall/SIF folder example XC103SecretClientCertificate.ps1
  • Execute the script and copy secret key to $CommerceEngineConnectClientSecret
$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$newClientSecret = [System.Convert]::ToBase64String($bytes)
echo $newClientSecret

13. [Optional] Update Sitecore domain or keep it default

  • $SitecoreDomain
  • $SitecoreUsername
  • $SitecoreUserPassword
  • $UserName
  • $UserPassword

14. Update other DB related settings

  • $SqlUser
  • $SqlPass
  • $SitecoreDbServer
  • $CommerceServicesDbServer

15. Update SOLR details-

  • $SolrUrl
  • $SolrRoot
  • $SolrService

Execute .\Deploy-Sitecore-Commerce.ps1

 .\Deploy-Sitecore-Commerce.ps1

Storefront-

Business Tools-

Highly recommended to install commerce on fresh VM or machine that don’t have previously installed Sitecore Commerce to avoid any errors during isntallation. If not then below are few of the errors you might see during installation.

Errors-

00007 10:12:17 ERROR CtxMsg.Error.ContentPathAlreadyExists: Text=Content path ‘/sitecore/Commerce/Commerce Control Panel’ already exists.


00038 10:12:17 ERROR Management.block.getitembypath: Sitecore Item Service Get item failed, Item /sitecore/Commerce/Commerce Control Panel/Commerce Engine Settings/Commerce Terms/System Messages/ContentPathAlreadyExists not found.

Solution- see here – https://robearlam.com/blog/CtxMsg-Error-ContentPathAlreadyExists-error

Loading

Step by step install Sitecore XC 10.2 using SIF on Windows 11

Follow these steps to install Sitecore Commerce 10.2 On Premise. To successfully install refer to Installation Guide provided by Sitecore.

Before installing Sitecore Commerce install Sitecore XP 10.2. See this blog to install Sitecore XP 10.2 using SIF. Say the XP site name is- xp0.sc

Download Installation Guide

Hosting Environment Requirements/ Download and Install following software-

  1. OS – Windows Server 2019/2016 or Windows 10 Pro(64-bit) or Windows 11 Pro(64-bit)
  2. Redis (Windows): 3.0.504 (or later)
  3. Database – Microsoft SQL Server 2017 Express Edition (This should be already installed as a part of XP 10)
  4. Install Microsoft Web Deploy 3.6 if not already installed
  5. Install URL Rewrite using Web Platform Installer
  6. SOLR 8.2.0 (This should have already installed as a part of XP 10 install)
  7. Install PowerShell 5.1 or later is not already installed
  8. Web Platform Transformer (Download nuget package)
  9. (Important) Install Web hosting- here

IMPORTANT – As per the release notes

The deployment of SXA has been removed from the Commerce installation, and instead installed as a Platform pre-requisite before installing Commerce packages.

Install Powershell Extension for Sitecore – Download Sitecore PowerShell Extension for Sitecore

Install Sitecore Experiemce Accelerator 10.2.0 – Download Sitecore Experience Accelerator 10.2.0

Also Commerce Ops service is removed from deployment configuration this will reduce deployment time and hosting cost.

Before starting the installation ensure XP 10.2 instance is working and indexed. If not indexed rebuild all search indexes-

Download Sitecore Experience Commerce 10.2

Step-by-step installation process-

  1. Create a installation folder for XC – xcinstall for e.g.- c:\scinstallation\xc

2. Copy and extract Sitecore.Commerce.WDP.2021.11-8.0.218.zip file to c:\scinstallation\xc folder

3. Copy Sitecore Experience Accelerator 10.2.0 rev. 04247.zip file c:\scinstallation\xc folder

4. Copy Sitecore.PowerShell.Extensions-6.3 – IAR.zip file to c:\scinstallation\xc folder

5. Extract Web Platform Transfomer nuget package and copy Microsoft.Web.XmlTransform.dll to c:\scinstallation\xc folder

6. Extract SIF.Sitecore.Commerce.7.0.37 to c:\scinstallation\xc folder. Rename this to SIF

7. Folder structure should look like this-

8. Install Sitecore.PowerShell.Extensions-6.3 – IAR.zip package in your earlier installed Sitecore instance

9. Install Sitecore Experience Accelerator 10.2.0 rev. 04247.zip pakcagein your earlier installed Sitecore instance

11. Open Deploy-Sitecore-Commerce.ps1 file in SIF folder to update the following-

  • $XCInstallRoot
  • $XCSIFInstallRoot = “$XCInstallRoot\SIF” or $PWD is fine – it is Present Working Directory,
  • $SiteNamePrefix
  • $SiteName
  • $SiteHostHeaderName [optional]
  • $MergeToolFullPath= “$XCInstallRoot\Microsoft.Web.XmlTransform.dll”
  • $CommerceServicesDbServer = “sc102comm\MSSQL2017”

12. Create Commerce Engine Connect Client Secret for the Sitecore Identity Server

  • Copy below script to file to scinstall/SIF.Sitecore.Commerce.5.0.49 folder example XC10SecretClientCertificate.ps1
  • Execute the script and copy secret key to $CommerceEngineConnectClientSecret
$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$newClientSecret = [System.Convert]::ToBase64String($bytes)
echo $newClientSecret

13. [Optional] Update Sitecore domain or keep it default

  • $SitecoreDomain
  • $SitecoreUsername
  • $SitecoreUserPassword
  • $UserName
  • $UserPassword

14. Update other DB related settings

  • $SqlUser
  • $SqlPass
  • $SitecoreDbServer
  • $CommerceServicesDbServer

15. Update SOLR details-

  • $SolrUrl
  • $SolrRoot
  • $SolrService

Execute Deploy-Sitecore-Commerce.ps1 script to install commerce

IMPORTANT – After deployment is complete Disable TLS 1.3 over TCP for all the sites and all bindings

Errors-

Error -The remote server returned an error: (400) Bad Request. on GetIdServerToken

Resolution – Check your admin credentials if correctly configured in installation script.

Error – Commerce roles site not reachable

Resolution- Check if the SSL certificate for Comerce Engine is in Trusted Root Certification Authorities. If not copy the relevant certs to same.

Sitecore Commerce Business Tools Compatibility Table

Sitecore Commerce installation package comes with Sitecore Business Tools SDK.

If you are planning to custommise Business Tools you might have to setup the development environment for Business Tools. You can find more information on how to setup the development environment here

For each version of Sitecore Commerce you need to install the specific version of Business Tools in you development environment.

See below the compatibility table for Business Tools with Sitecore commerce-

Package for the same can be found here

Sitecore Commerce (XC) VersionSitecore Business Tools VersionDownload Link
10.27.0.6https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/7.0.6
10.16.0.6https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/6.0.6
10.05.0.12https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/5.0.12
9.34.0.8https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/4.0.8
9.23.0.7https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/3.0.7
9.12.0.3https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/2.0.3
9.0.31.4.1https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/1.4.1
9.0.21.2.19https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/1.2.19
9.0.11.1.9https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/1.1.9
9.0.01.0.572https://sitecore.myget.org/feed/sc-npm-packages/package/npm/@sitecore/bizfx/1.0.572

Install Sitecore 9.0.2 – Cannot process argument transformation on parameter ‘Signer’

If you see this error whilst installing Sitecore 9.0.2 the issue might be due to multiple certificates been issues.

In this case delete both certificates listed –

Get-ChildItem Cert:\LocalMachine\Root\<<Thumbprint>> | Remove-Item

Try the installation again

ERROR-

SOLUTION-

Check and remove – DO_NOT_TRUST_SitecoreRootCert if its expired from Local Computer and Current User.

Also remove the same form the dis mainly from C:\certificates

ERROR-

SOLUTION-

Sitecore XC 10 – code breaking changes

Sitecore Commerce 10

Sitecore Commerce supports integration to the third-part system and customization and extension to the OOTB entities. This can be achieved by custom plugins.

If you are migrating your code from XC 9.x version to XC 10 you will have to update the code to newest API’s provided with XC. Following is the list of breaking changes if migrating from older versions or good to know if you are starting with the new XC 10 solution.

Wrappers to PipelineBlock

Commerce Engine uses pipeline framework to support extensibility. Pipelines act as a containers for business logic. Commerce pipeline consists of a block which has a detailed business logic.

With Sitecore 10 PipelineBlock are now wrapped with AsyncPipeline and SyncPipeline. So if you have your code using PipelineBlock it should be using Run method to execute the block you may have injected to pipeline.

AsyncPipelineBlock

If block needs to be executed Asynchronously use AsyncPipelineBlock. Also the method name changes to RunAsync()

SyncPipelineBlock

If block needs to be executed Synchronously use SyncPipelineBlock. The method name used to execute block is Run()

ConfigureServiceApiBlock also now uses SyncPipelineBlock

2. IPipeline RunAsync() method

IPipeline interface method is changed from Run to RunAsync() which now makes sense as the method is asynchronous operation.

So where are the changes you might need to make, some of the pipelines that is used frequently and need change are listed below-

  1. IFindEntityPipeline
  2. IFindEntitiesInListPipeline
  3. IFindEntitiesPipeline
  4. IPersistEntityPipeline
  5. Any custom pipeline and list goes on…

Api Controller

Commerce api controller exposes the endpoint to communicate from FE or Commerce Connect to Commerce Engine. You can create custom endpoint and the api controller inherited from class CommerceController.

With XC 10.x the class file to inherit for same is CommerceODataController

See this link for more details – CommerceODataController

ODataActionParameters

ODataActionParameters should now be referenced from Microsoft.AspNet.OData namespace.

FileResultExecutorBase

FileResultExecutorBase should be referenced from Microsoft.AspNetCore.Mvc.Infrastructure

These are few of the breaking changes. There are more and I shall keep updating.

Sitecore Commerce 10- Setup Development Environment for Business Tools – Part 1

Business Tools is extensible using pluggable framework and can extend a UI using Entity Views. Although Business Tools offers a rich set of controls you might want to create your own custom control for the best business experience.

For this you need to first setup the development environment for business tools. Once the environment is setup you should be ready to develop custom control/customize the business tools.

Prerequisites

  1. Instance of Commerce Engine deployed in development environment
  2. Install Node.js Javascript runtime
  3. Install Angular CLI tool – npm install -g @angular/cli

NPM configuration to have NPM Packages from Sitecore public feed

Sitecore BizFx SDK relies on NPM packages available on the Sitecore official public feed for NPM packages.

Open Poswershell as Administrator

Execute these 2 commands in powershell

npm config set @speak:registry=https://sitecore.myget.org/F/sc-npm-packages/npm/

npm config set @sitecore:registry=https://sitecore.myget.org/F/sc-npm-packages/npm/

This will add following line to–

C:\Users\[your user]\.npmrc

[Optional] – you may check if this lines are added

@speak:registry=https://sitecore.myget.org/F/sc-npm-packages/npm/
@sitecore:registry=https://sitecore.myget.org/F/sc-npm-packages/npm/

Setup and Install SPEAK and BizFx packages for development solution

Copy Sitecore.BizFX.SDK.4.0.8 folder to your development folder and extract the SDK zip file to folder e.g. c:\BizFXDevelopment\SitecoreBizFx

Copy below files to the folder SDK was extracted. You should find this files from the Sitecore XC release package.

  1. speak-icon-fonts-1.1.0.tgz
  2. speak-ng-bcl-2.0.0-r00116.tgz
  3. speak-styling-1.0.0-r00110.tgz

Execute the following commands where the above files were copied

​​​​​​​npm install speak-icon-fonts-1.1.0.tgz
​​​​​​​npm install speak-ng-bcl-2.0.0-r00116.tgz
npm install speak-styling-1.0.0-r00110.tgz
npm install @sitecore/bizfx

Run npm install. This should install required npm modules and add a folder node_modules

npm install

Setup the business tools config.json with your deployment configuration

Once the npm installed successfully open config.json file located in src\assets folder

Update the config to the same as the BizFx site instance except for BizFxUri. Note BizFxUri points to http in below config

{
  "EnvironmentName": "HabitatAuthoring",
  "EngineUri": "https://localhost:5000",
  "IdentityServerUri": "https://xp10.IdentityServer",
  "BizFxUri": "http://localhost:4200",
  "Language": "en",
  "ContentLanguage": "en",
  "Currency": "USD",
  "ShopName": "CommerceEngineDefaultStorefront",
  "LanguageCookieName": "selectedLanguage",
  "ContentLanguageCookieName": "selectedContentLanguage",
  "EnvironmentCookieName": "selectedEnvironment",
  "AutoCompleteTimeout_ms": 300,
  "AccessTokenUpdateInterval_ms": 300000
}

Run the development environment

Important!

Stop the SitecoreBizFx site as the site listens to 4200 port. Next step will help listen the site from the extracted SDK folder.

Execute following Powershell command –

ng server

Open browser on http://localhost:4200/ this should ask to enter the Sitecore client credentials, once provided it will throw an error

This site can’t provide a secure connection

The reason this error occurs the identity server is not configure to server BizFx site on http

Update the Sitecore Identity Server Configuration

Open the Sitecore.Commerce.Identity ServiceHost.xml from the installed Identity Server instance \wwwroot\Config\production

Add http://localhost:4200 to AllowedCorsOriginGroup1

<AllowedCorsOrigins>
<AllowedCorsOriginsGroup1>http://localhost:4200</AllowedCorsOriginsGroup1>
</AllowedCorsOrigins>

Update Commerce Engine configuration

  • Open config.json from wwwroot folder in CommerceAuthoring site
  • Update AllowedOrigins in AppSettings to have http://localhost:4200
  • Since the config is changed need to bootstrap so the changes are applied to authoring site
  • Restart IIS. Optionally you may just restart Commerce Authoring site

Run Business tool from development environment

Open browser on http://localhost:4200/

Business tools running on http and in developer mode.

References –

step-by-step instructions on how to setup and compile the Business Tools (BizFX) application using the ​Sitecore.BizFX.SDK

Stay tuned next blog will walk through on how to create a new custom control/component in Business Tools

This image has an empty alt attribute; its file name is image-43.png

How to resolve user registration error in Sitecore Commerce- “Invalid or missing value for property Domain .”,”User created but external Id was not provided”

Are you wondering why this error occurred while registering user?

You may come across this error when the engine is trying to create a customer in Commerce and the domain you have created for Storefront is not available in Commerce. The customer in commerce are mapped to the domain and if the domain is not found or matched with what is configured in Storefront this error will come.

So how to resolve this error-

Lets say your Storefront is mapped to use the default environment i.e. HabitatShops.

Follow steps below to make this work-

  • Open PlugIn.Habitat.CommerceAuthoring-1.0.0.json and find the CustomerPropertiesPolicy
  • You may see the list of Domains default been Storefront, extranet and CommerceUsers
  • Add the domain you have configured in your storefront in this list e.g.:- HabitatStorefront
  • Add the same domain to PlugIn.Habitat.CommerceShops-1.0.0.json
  • Ensure the domain is created and mapped in the Storefront correctly
  • Bootstrap Habitat Environment using Postman and now you should see the domain in the list whilst creating a customer

You should now able to see the domain in the list whilst creating a customer in business tool

Should also allow to create a customer with the new domain-

Hope this helps.

Enable Catalog search in business tool for Sitecore 9.1 Commerce environments

Sitecore Commerce indexes Catalogs, Categories and SellableItems to help search items in Business tools. The settings for the Search can be found in PlugIn.Search.PolicySet-1.0.0.json

These indexes has a search scope, for searching catalog and related items by default the scope is “xc910CatalogItemsScope”

So in SOLR indexed items related to catalogs are kept in core – “xc910CatalogItemsScope”

By default Sitecore will index only Habitat Environment in Sitecore Commerce 9.1. If you want to index your custom environment or AdventureWorks environment, follow these steps-

  • Open Sitecore.Commerce.Engine.Connectors.Index.Common.config file. This should be in CM Y.Commerce.Engine folder
  • In this instance for Adventureworks add “AdventureWorksAuthoring” in Environemnts element for Master Index and “AdventureWorksShops” for Web Index
  • Open Postman and Run – Full Index Minion Catalog Items
  • Check if the items are indexed correctly in SOLR.
  • Search the same keyword in Business tool for AdeventureWorks environment

Sitecore commerce – No catalog data available

Sitecore Storefront can have multiple catalogs, but only one catalog can be used to each Storefront.

At times whilst development you might have to switch between the Authoring site and Visual Studio Commerce Engine Solution for debugging. I have seen sometimes the Catalog for the Storefront is reset during the switch which results in error – No catalog data available.

This message is shown on the menu as seen in the screenshot-

ErrorNoCatalogDataAvailable

ErrorNoCatalogDataAvailable2

Solution-

Login to Sitecore Client and follow these steps-

  1. Navigate to following location in Content Editor-  /sitecore/content/Sitecore/Storefront/Home/CatalogsSelectCatalog
  2. If none of the Catalog is selected, please select the Catalog and Save. In this case Habitat_Master
  3. Should now display the menu as the Catalog details are now setupErrorNoCatalogDataAvailable1

You also might need to consider checking Catalog Configuration here – /sitecore/content/Sitecore/Storefront/Settings/Commerce/Catalog Configuration

Setup the Catalog and Start Navigation Category

CatalogConfiguration

 

Hope this helps.

 

 

Sitecore Commerce environments- configure and access environment policy

Environments in Sitecore XC are used to control the configuration policies that defines behavior. Define a Commerce environment in the environment configuration JSON file. JSON file contains information specific to Commerce Engine policies that needs to be implemented for specific environment for example Habitat Authoring.

In this article will show how to configure the policy in a specific environment JSON file and access the policy that affects the behavior based on the settings.

First check the default environment. Open Sitecore.Commerce.Engine.Connect.config and see

<defaultEnvironment>HabitatAuthoring</defaultEnvironment>

In this case will add a setting to include Sitecore Clinet Url in enviornment-

Open Comerce Authoring – wwwroot\data\Environments folder

Since the default environment is HabitatAuthoring, you should update PlugIn.Habitat.CommerceAuthoring-1.0.0.json file-

{
"$type": "Sample.Commerce.Plugin.Management.Policies.SitecoreCmsServerPolicy, Sample.Commerce.Plugin.Management",
"ServerHostName": "https://mystorefront.local/"
},

Restart IIS. Hope you already know how to run the Commerce Ops script using postman.

Open Postman, run the GetToken and in SitecoreCommerce_DevOps

run Bootstrap Sitecore Commerce.

This should sync the environment related changes.

Assuming you have a plugin. Create a policy in  Sample.Commerce.Plugin.Management.Policies namespace with the class SitecoreCmsServerPolicy inherited from Policy as below-

using Sitecore.Commerce.Core;

namespace Sample.Commerce.Plugin.Management.Policies
{

public class SitecoreCmsServerPolicy: Policy
{
public string ServerHostName { get; set; }
}
}

You can use the environment configurations by getting the policy as folloes-

var cmsSitecoreServerPolicy = context.GetPolicy<SitecoreCmsServerPolicy>();

cmsSitecoreServerPolicy.ServerHostName;

You should now get the value “https://mystorefront.local/” when ServerHostName is accessed.

You may update these environment files- PlugIn.Habitat.CommerceShops-1.0.0.json for shops environment

Hope this helps.

 

Reference- Commerce Engine environments