Category: Commerce

Sitecore Commerce – Promotion Dashboard and creating Promotion Book in Business Tool

1. Promotion dashboard

Promotion dashboard shows all Promotion Book where all the Promotions are kept. Dashboard allows to add new Promo book.

PromoDashboard

2. Creating a Promo Book

All promotions are organised in a promo book. The list of promotion books on the Promotion dashboard is shown in alphabetical order. Promotion dashboard has options to Add new promotion book. By default Habitat_PromotionBook is created in the Commerce is installed.

To add new promotion book click on Add icon. This should show the popup to add a new promo book.

PromoBookAdd

Promo book with same name cannot be added.

PromoBookAddError1

Promo book name should not exceed 50 characters.

PromoBookAddError2

 

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

 

 

 

 

 

 

Sitecore commerce (XC) 9.2 installation errors

Whilst installing XC 9.2 I faced following issues, these are basic issues but as a newbie was a good learning and a in depth understanding of the configurations and tasks required to get the commerce installed.

Configuration contains no tasks

This was the trickiest issue. XC9.2 required SIF 2.1.0, you might have installed this version but if you have multiple versions of SIF you might have to switch to SIF 2.1.0 whilst installing the XC9.2

Following is the coupe of lines, end of the scripts ends during installation-

VERBOSE: Registering Task extension ‘TestWebFeatureSSL’ => ‘Test-WebFeatureSSL’
VERBOSE: Registering task parameter map
VERBOSE: WarningAction => Continue
VERBOSE: Verbose => Continue
VERBOSE: InformationAction => Continue
VERBOSE: WhatIf => False
VERBOSE: Debug => SilentlyContinue
VERBOSE: ErrorAction => Stop
WARNING: Configuration contains no tasks
[TIME] 00:00:00

Solution to issue-

Check the version of SIF active in the powershell or currently used with following command-

Get-Command -Module SitecoreInstallFramework | Select-Object -Property name, version

XC1

Resolution-

If it shows V1.2.1 switch to version 2.1.0 but ensure the this version is installed. To switch to the new version-

Remove-Module -Name SitecoreInstallFramework
Import-Module -Name SitecoreInstallFramework -RequiredVersion 2.1.0

This should allow you to proceed with the instllation.

How I found this might be the issue-

Firstly its a pre-requisite to XC9.2, SIF 2.1. is required.

When I ran the installation script it showed this screen. It shows SIF version as 1.2.1, this were I guessed version might be wrong.

Logs didn’t mention the same.

ConfigurationTask

https://sitecore.stackexchange.com/questions/20791/xc-9-2-installation-error-configuration-contains-no-tasks

.Net SqlClient Data Provider: Invalid object name ‘Blobs’

This happens to be another silly mistake I made in the script file where I mentioned wrong site name prefix.

Found that it tries to update the Blobs and other tables in XP instance i.e. YourSitecoreXP_Master DB

So if the Sitecore prefix in the deploy script is wrong it tries to create a new database and update the Blobs table which is not available and hence fails.

 

XC2

Resolution-

So please check $SiteNamePrefix in deploy script, should match to the XP prefix. e.g.- if your Sitecore XP site name is storefront920.local so the database will be created as storefront920_Master. So in this case $SiteNamePrefix will have to be storefront920

Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error

If you see this error-

VERBOSE: Result: https://commerceshops.sc920.local/commerceops/Bootstrap()
BootStrapping Commerce Services: https://commerceshops.sc920.local/commerceops/Bootstrap()
VERBOSE: PUT https://commerceshops.sc920.local/commerceops/Bootstrap() with 0-byte payload
Install-SitecoreConfiguration : The remote server returned an error: (500) Internal Server Error.
At E:\sc_com_install\SIF\sc_com_install.ps1:100 char:1
+ Install-SitecoreConfiguration @params -Verbose *>&1 | Tee-Object “$PS …
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration

Resolution-

Managed to resolve this issue by updating the Sql database name to have double slash “\\” between the machine name and sql instance.

This is applies to following paramsters in script-

CommerceServicesDbServer and SitecoreDbServer

e.g.:- machinename\\sql-instance

Could not load file or assembly (Microsoft.Web.XmlTransform.dll)

If you see below error even if the file is present in the desired location, Unblock the file to continue the installation.

XCERROR

Go to directory having files Microsoft.Web.XmlTransform.dll. Right click the dll and Unblock the dll

scerror2

If you still see this issue, provide the relative path to the dll in script file for parameter – MergeToolFullPath