Category: Commerce

Options to Install Sitecore (XP) and Commerce (XC) 10

If you are looking for upgrade to Sitecore 10, below are the various options you are able to install Sitecore 10.

Sitecore XP 10

Sitecore Installation Assistant (SIA)

Sitecore Installation Assistant helps guides you through the Sitecore XP Developer Workstation installation. Use this option to review system requirements, install prerequisites and complete the entire installation process. With Sitecore 10 you have a option to also install SXA with SIA.

To install Sitecore 10 using SIA follow this post- Step-by-step how to install Sitecore 10 using SIA

Sitecore Installation Framework On-Premises (SIF)

Sitecore Install Framework (SIF) is a Microsoft PowerShell module that supports local and remote installations of Sitecore Experience Platform.

SIF deploys Web Deploy Packages (WDP) by passing parameters to SIF configuration through a Microsoft PowerShell module and is fully extensible.
The Sitecore Experience Platform is designed to be secure-by-default. For developer environments all the required self-signed certificates are created automatically if you do not provide any.
In a production environment, you can provide your own certificates In a non-production environment, you can choose to have the module generate the certificates for you.

You must set up SIF before you can install Sitecore Experience Platform

To install Sitecore XP 10 using SIF follow this post – Step-by-step install Sitecore XP 10 using Sitecore Installation Framework (SIF)

Sitecore Containers

Sitecore Containers support rapid deployment and more efficient solution and team onboarding with modern Docker and Kubernetes technology.

Sitecore Experience Platform 10.0.0 uses Docker Compose as the container
orchestrator on developer workstations. Docker Compose is a simple containerdeployment tool that is bundled with Docker for Windows. Sitecore container images can be deployed with other tools but we recommend that you use Docker Compose to deploy the containers that form the Sitecore Experience Platform.

To install Sitecore XP 10 using Sitecore Containers with Docker Compose- Step-by-step install Sitecore XP 10 to developer workstation using Sitecore Containers with Docker Compose

Sitecore XC 10

Sitecore Installation Framework (SIF)

Sitecore Install Framework (SIF) is a Microsoft PowerShell module that supports local and remote installations of Sitecore Experience Platform.

The SIF.Sitecore.Commerce package contains Sitecore Installation Framework scripts and Web Deployment Packages (WDP).

To install Step-by-step install Sitecore Commerce (XC) 10

Step-by-step install Sitecore Commerce (XC) 10

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

Login to Sitecore before starting download.

Download Installation Guide

Before installing Sitecore Commerce install Sitecore XP 10. See this blog to install Sitecore XP 10 using SIA. Say the XP site name is- sc10.sc.dev.local

Hosting Environment Requirements/ Download and Install following software-

  1. OS – Windows Server 2019/2016 or Windows 10 Pro(64-bit)
  2. Redis (Windows): 3.0.504
  3. .Net Framework – ASP.Net Core runtime 3.1.6 (Recommend to install v3.1.7 it has a security patch)
  4. Database – Microsoft SQL Server 2017 Express Edition (This should be already installed as a part of XP 10)
  5. Install Microsoft Web Deploy 3.6 if not already installed
  6. Install URL Rewrite using Web Platform Installer
  7. SOLR 8.4.0 (This should have already installed as a part of XP 10 install)
  8. Install PowerShell 6.0 or later is not already installed
  9. Web Platform Transformer (Download nuget package)

Download following Sitecore Software before XC installation

Require login before downloading the Sitecore Softwares

Sitecore Experience Platform 10.0

Sitecore Experience Accelerator (SXA) 10.0

Sitecore PowerShell Extensions 6.0 for Sitecore 10.0

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

Also check if the SOLR is working and running on https-

Step-by-step installation process-

  1. Create a installation folder for XC – xcinstall for e.g.:- c:\scinstall
  2. Copy Sitecore.Commerce.WDP.2020.08-6.0.238.zip file to c:\scinstall folder
  3. Extract and copy all extracted files to the c:\scinstall folder
  4. Copy Sitecore Experience Accelerator. Copy Sitecore Experience Accelerator 10.0.0.3138.zip file c:\scinstall folder
  5. Copy Sitecore.PowerShell.Extensions. Copy Sitecore.PowerShell.Extensions-6.1.1.zip file to c:\scinstall folder
  6. Extract Web Platform Transfomer nuget package and copy Microsoft.Web.XmlTransform.dll to c:\scinstall folder
  7. Extract SIF.Sitecore.Commerce.5.0.49 to c:\scinstall folder
  8. Folder structure should look like this-
  9. Open Deploy-Sitecore-Commerce.ps1 file to update the following-
    1. $SiteNamePrefix
    2. $SiteName
    3. $IdentityServerSiteName
    4. $SiteHostHeaderName
    5. $XConnectInstallDir
    6. $MergeToolFullPath – Path of the Microsoft.Web.XmlTransform.dll
  10. Update DB related configuration
    1. $SitecoreDbServer – In case of named instance ensure you set double slash between the server and instance name “SQLServerName\\SQLInstanceName”
  11. Update other DB related settings
    1. $SqlUser
    2. $SqlPass
    3. $CommerceServicesDbServer
  12. [Optional] Update Sitecore domain or keep it default-
    1. $SitecoreDomain
    2. $SitecoreUsername
    3. $SitecoreUserPassword
  13. Update SOLR details-
    1. $SolrUrl
    2. $SolrRoot
    3. $SolrService
  14. [Optional] Update local account details
    1. $UserDomain
    2. $UserName
    3. $UserPassword
  15. Create Commerce Engine Connect Client Secret for the Sitecore Identity Server
    1. Copy below script to file to scinstall/SIF.Sitecore.Commerce.5.0.49 folder example XC10SecretClientCertificate.ps1
    2. Execute the script and copy secret key
$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$newClientSecret = [System.Convert]::ToBase64String($bytes)

Write-Host $newClientSecret

16. Copy the secret key to update $CommerceEngineConnectClientSecret variable in Deploy-Sitecore-Commerce.ps1

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

18. Once installed successfully login to Sitecore, you shall find the Business tool in Dashboard

19. Goto content editor and navigate to item- /sitecore/content/Sitecore/Storefront/Settings/Site Grouping/Storefront to change Host Name

20. Visit site to check if the default store front site is loading

21. Login to Business Tools

Issues

  1. Error connecting Identity Server. See this blog to resolve if you receive error

2. Error whilst bootstrapping commerce ops

Resolution- Check or reset the service account credentials that are created for the app pools as part of deployment. You can find the credentials in installation script with variable name $UserName (CSFndRuntimeUser) and $Password. Try accessing the https://commerceops.sc.com site if there are any other errors.

Install Sitecore XP 10 using Sitecore Installation Assistant(SIA) in easy steps to development machine

Installing Sitecore 10 with Sitecore Installation Assistant (SIA) is quick and easy. Only manual prerequisite is to install SQL Server 2017

Please see through screens to install Sitecore 10-

Step 1- Install SQL Server 2017 and SQL Server Management Studio (SSMS)

Step 2- Download Sitecore 10 Graphical setup package for XP Single

Step 3- Extract the zip and start setup

Step 4-

Step 5- Install prerequisite. This should install SIF and Windows Server prerequisites including IIS and modules etc.

Step 6 – Once prerequisites are installed successfully yo may have to restart machine. Install Solr search service. Sitecore 10 needs SOLR 8.4

Step 7- After SOLR is installed enter the Sitecore settings along with SQL server details and SOLR details

Step 8 – Optionally select Sitecore modules (SXA)

That’s it and everything is managed by SIA to sucessfuly install Sitecore 10 on machine

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.

Elements of a Sitecore Commerce Plugin project template

In my previous post we saw the first step to create a new plugin by adding a new plugin project to the solution, restoring the correct binaries and reference new plugin to the Engine project.

In this post I will share what comes with the Plugin project template.

Sitecore Commerce Plugin project template creates folders and classes which helps to quick start creating a plugin, lets see what are these files –

1. Commands

To my understanding command is unit of work to perform set of actions. Commands allows to execute a pipeline and blocks within a transaction scope. Create a custom command by inheriting from CommerceCommand class. Use PerformTransaction method to run a pipeline in a transaction scope.

2. Components

If you want to extend existing or custom entities, use component. Component has attributes that support entities.

3. Controllers –

Controllers expose commerce functionality implemented in plugins. They are the api endpoints. Sitecore Commerce has various Controller type- Entity, Api, Devops and Command. Create your own controllers by inheriting from CommerceController

4. Entities-

They are the persistable unit and represent the business concept. Inherited from the CommerceEntity they has a unique identifier that helps to retrieve the entity by using a Entity controller type.

5. Models –

They are the POCO classes that are reusable in entities and components. Can be used to present data as part of command response .

6. Pipelines – They do the heavy lifting in plugin by making it possible to define the extensible behavior. Create your own pipeline and add blocks you want to execute to implement your business logic. Blocks within pipelines execute in a sequence they are registered.

7. Policies

Policies defines behavior for the functionality provided by the plugin. Its is recommended to not extend or inherit out-of-box plugins instead create your own. Plugins can be changed or created new by updating the JSON files provided in environment folder of the various roles site.

ConfigureSitecore

ConfigureSitecore class helps to register the pipeline and block definitions that a plugin defines. You can create a new plugin and AddPipeline or extend the existing pipeline by adding a block After or Before any existing blocks. ConfigureSitecore class registers pipelines every time engine loads. You can also register commands or register your custom class in this class.

ConfigureServiceApiBlock

This registers customer entities, components and controller action with ODATA model. It allows to these elements to be used when a REST API call is made and available when generating a proxy.

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

First Steps | Sitecore Commerce Development | Create a Custom Plugin

In my last post, I have described the steps to set up the Sitecore Commerce development environment. In this post, I will describe how to create a custom plugin in Sitecore Commerce. I was working on version 9.3 but these steps should work with all versions of 9 series.

Sitecore Commerce provides an extensible framework which can be extended using plugins. A plugin is an independently publishable extension to the Sitecore Commerce Engine. Generally, you will find the following contained in a plugin and are used to extend the platform.

  • Entities
  • Components
  • Entity Views
  • Pipeline
  • Policies etc.

You can extend the platform or add more features using the plugins. Let’s get started and look into the steps to create a new plugin in Sitecore Commerce 9.3. If you have already set up your commerce development environment, please skip to step 2

Step 1 – Setup developer environment

Create a developer environment for Sitecore Commerce to run the engine from Visual Studio, can be either VS 2017 or 2019. Follow this blog post for same Setup development environment for Sitecore Commerce 9.3 Engine

Step 2 – Install Visual Studio Extension for creating plugin

  1. Go to  solution root folder or SDK folder and run the Sitecore.Commerce.Plugin.vsix file. Close the Visual Studio solution if open.
  2. This should install extension on selected Visual Studio Version
create plugin1

Step 3 – Create a plugin

  1. Open your solution. Create a Feature solution folder, just to follow Helix best practice. Right click solution folder to create a new project
  2. Search Sitecore.Commerce.Plugin. Select project type and click next.
create plugin2
  1. Give the project name, location and select .Net Framework 4.7.1. Create a Project.
create plugin3
  1. Sample Folder and Files for Commands, Components, Controller etc shall be added.
create plugin4
  1. Update the Sitecore Commerce Core from 5.0.0 to 5.0.4
create plugin5
create plugin6

4. Build the project. There shouldn’t be any reason the build should fail.

Step 4 – Reference project and run engine

  1. Add Plugin project reference to your Commerce.Engine Project
  2. Run the Engine. You should be able to see the newly created plugin is now registered in Engine.

This should allow to start customizing commerce and truly use plug-gable and extendable feature of Sitecore Commerce.

create plugin9

We intentionally didn’t add any code to this plugin to keep this simple. In the next blog, we will cover the anatomy of the newly created plugin and show how to inject this plugin into Commerce Pipelines and execute some custom code.

Next understand the Elements of Sitecore Commerce Plugin project templates

Hope you enjoyed this post. Stay tuned.

Step-by-step – Setup development environment for Sitecore Commerce 9.3 Engine

On a XC installed instance you might want to customize the XC by adding your own Entities, Components, Entity Views etc. In this topic I will describe how to setup your development environment to add your custom plugin.

This topic assumes a Sitecore CMS and Commerce engine version 9.3 are running under IIS. I am using Visual Studio 2019.

Steps to setup-

Step 1- Extract Commerce Engine SDK

  1. Copy the downloaded SDK Sitecore.Commerce.Engine.SDK.5.0.76.zip on your development folder.
  2. If not available you may download Packages for On Premise WDP 2020.01-5.0.145
  3. Extract the commerce package and then extract Sitecore.Commerce.Engine.SDK.5.0.76.zip
Extracted files

Step 2 – Setup Visual Studio Solution

  1. Open the Solution, by default this is Customer.Sample.Solution.sln
  2. Ensure Package Source is configured for Commerce- https://sitecore.myget.org/F/sc-commerce-packages/api/v3/index.json
  3. Build the Solution. It should restore the package and build successfully.
  4. (optional)Rename the Solution name. In this case I have renamed to Retail.Commerce
  5. (Optional) Create a solution folder “Project” and move Sitecore.Commerce.Engine project
  6. (Optional) Rename “Sitecore.Commerce.Engine” project to “Retail.Commerce.Engine”. Re reference AdventureWorks, Habitat and BrainTree projects if required. Adjust/rename namespace in classes.
  7. (Optional) Create Foundation and Feature projects. Build the solution again.
CompileVS

Step 3 – Generate Development Certificate

Generate development certificate using script “New-DevelopmentCertificate”, so the localhost runs on SSL(https)

  1. Open powershell script and navigate to scripts folder.
  2. Execute New-DevelopmentCertificate script
  3. Change the Path($certificateOutputDirectory) if required. Certificate should be copied to \src\Project\Engine\code\wwwroot
generate_certificate
generate_certificate1

Step 4 – Update configuration

  1. Change environment in Engine project/wwwroot/config.json file to HabitatAuthoring
  2. Change “SitecoreIdentityServerUrl”: “https://storefront930.identityserver.local”,
  3. Add the site name in AllowedOrigins in config.json
  4. Open Global.json in  wwwroot/bootstrap folder in Engine project
  5. Update SQL Server, UserName and Password in EntityStoreSqlPolicy
  6. Check the database name
globalconfig1

7. Update Host to your site host name in SitecoreConnectionPolicy

globalconfig2

Note: You may copy the config.json and gloal.json file from Authoring Site hosted in IIS to your project, but to better understand the changes required I have noted the changes. 

Step 5 – Update allowed origins in Identity Site

  1. Open Sitecore.Commerce.IdentityServer.Host.xml file. Should be in /config/production/Sitecore.Commerce.IdentityServer.Host.xml
  2. Navigate to section <CommerceEngineConnectClient><AllowedCorsOrigins>
  3. Add https://localhost:5000 to the

Step 6 – Ready for running the Engine

  1. Set Engine as your Startup Project
  2. Change the debug profile to “Engine” instead of “IIS Express”
  3. In IIS stop Authoring site. i.e. for your default instance it might be CommerceAuthoring_sc930 site
  4. Run the Engine from Visual Studio. This will open the console.
  5. Once the plugins are instantiated, it should listen to 5000 port. At this point you have configured Engine to run/debug from Visual Studio. Any calls from the business tool should be received by engine and console should be able to show the request that’s been received.
RunVSComm1
RunVSComm3

And here we have business tool sending request to engine running on Visual Studio, see GetNavigationView() been called in console-

Bixfx
RunVSComm4

Sitecore Commerce – Product listing page error- The Layout for the requested document was not found

Each Storefront in Sitecore Commerce has its own Storefront settings and Catalog configuration. Whilst configuring multiple environment in a single Commerce instance you might come up with the layout not found error on the Product Listing or Details page.

StorefrontConfiguration

If you see the image above the path is directly been severed from Sitecore Content i.e. a direct navigation is used. To resolve this issue goto- /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts/Storefront/Catalog Configuration

Uncheck Use Direct Navigation

StorefrontConfiguration_resolve

The product listing and details page should be shown.

StorefrontConfiguration_resolve)product

 

Step by Step – Create promotions in Sitecore Commerce 9.3

Who don’t like discounts. People eagerly wait for Black Friday or Christmas offers. During festive these are the discounts applied mostly without a promo codes. When its no festive period you may still find the discounts but those asks for promo codes i.e. coupons.

giphypromo

In this article I will walk through how to create and setup the promotions in Sitecore Commerce 9.3  by defining qualifications, benefits and coupons. How the discounts are automatically applied when Public Coupons are set and how to restrict an auto discounts by setting private coupons.

I assume you have installed Sitecore Experience and Commerce 9.3.

See these links more details on Creating and Setting Promotions step by step

Step 1- Promotion dashboard and Promotion Book

To be continued…