Page 12 of 21

Step-by-step install Sitecore XP 10.1 to developer workstation using Sitecore Containers with Docker

To know more about containers here is the official documentation from Sitecore on Containers

Lets get started to create a Sitecore XP 10.1 development environment using docker.

Before getting started please see Installation Guide for Developer Workstation with Containers

Topology user here will XP0 or per guide XP Workstation (XP Single)

Hardware and Networking Requirements-

Sitecore instance needs below ports, avoid using these ports other than Sitecore.

Required portRoleDescription
443TraefikHTTPS proxy
8079TraefikTraefik dashboard
8984SolrSolr API and dashboard
14330SQLSQL Server

Prepare/prerequisite for Sitecore XP workstation

  • [Optional] OS- Windows 10 1809 or later or Windows Server 1809 or later

Login to Azure portal to create a VM

Image – Select Image to Windows 10 Pro, Version 1809- Gen 1

Size – Standard_D8s_v3- * vcpus, 32GiB memory

Inbound ports– Select RDP, dont select HTTPS 443 as this will be used by Traefik as mentioned in previous section

  • Download and Install Docker Desktop for Windows

Download and install Docker Desktop for Windows. You can get Stable version from here

After installation Restart the machine, this should enable the Hyper-V feature

This should also have Docker running and should see the same in system tray

  • Switch to Windows containers

Right click on Docker icon and switch to Windows Container. See this link for more details as per guide

Download and Prepare for installation

  • Download and extract the Sitecore Container Deployment Package from the Sitecore Developer Portal and store it on your local workstation or check releases here
  • Copy and extract SitecoreContainerDeployment.10.1.0.005207.309.zip for e.g:- C:/sc101_install

Navigate to C:\sc101_install\compose\ltsc2019\xp0

  • Open .env file, we need to fill in this parameters before starting installation. You can find more details in guide for each option.
  • Download PowerShell script to initialize (init.ps1) the parameters from docker-examples. Parameter values in .env can be populated manually by individually executing the commands for required for each parameter in guide(see Appendices) but I would recommend to use init.ps1 as this is provided by Sitecore and hence tried and tested.

Folder structure should look like this-

  • Change parameter values in init.ps1 file.

Change the SitecoreAdminPassword, SqlSaPassword and host entries as per requirement. If you are changing host entries also ensure the same is updated in .env file for CM_HOST and ID_HOST parameters. Lets keep the default values.

  • Populate .env file using init command

Open PowerShell as a Administrator, navigate to the folder having init.ps1 file.

Execute init.ps1 script. You may have to set the execution rights to current user to execute the script-

Set-ExecutionPolicy -Scope CurrentUser Unrestricted
.init.ps1

Provide the path of license file

This should Install and Import SitecoreDockerTools and Populate the environment file.

Ensure to Switch to Windows Container before executing below command

Install

Execute docker compose command

docker-compose.exe up --detach

Installation complete-

Once command execution is complete, should see all the checks done and Sitecore dev. instance ready in 20 minutes

Open Docker Dashboard and should see Sitecore-XP0 running

Site listening to address- https://xp0cm.localhost/

Cleanup the workstation

To cleanup/stop workstation use following commands. You can find these in instllation guide

To stop a Docker Compose environment without removing its contents:

docker-compose.exe stop

To resume a previously stopped Docker Compose environment:

docker-compose.exe start

To remove a Docker Compose environment and all the non-mounted volumes

docker-compose.exe down

Hope this helps to install Sitecore XP 10.1 using Docker!!!

Step-by-step install Sitecore XP 10.1 using Sitecore Installation Framework (SIF)

install

To install XP Single Developer(XP0) 10.1 on development machine, follow the steps in this blog post

Use the Sitecore Installation Guide for hardware, OS, database and other software requirements

Installation guide for Developer workstation

Download/Install following-

  • Windows Server 2019/2016 or Windows 10(64-bit)
  • Install Microsoft PowerShell 7.0.3 if not already installed
    1. PowerShell in installed with OS. Check version using this command
      • Get-Host | Select-Object Version
    2. Optionally install version 7.0.3 if version 5.1 or later is already installed
  • Install .Net Framework 4.8.0

Machine restart might be required whilst installation of above software’s

Step-by-step prepare and organize pre-requisite and installation files

  • Enable Contained Database Authentication

After installing SQL Server launch SQL Server Management Studio and run following-

EXEC sp_configure 'contained', 1;
 RECONFIGURE;
  • Prepare the installation folder
  1. Extract downloaded XP Single Developer package to a folder e.g.:- sc101_install
  2. Extract XP0 Configuration files 10.1.0 rev. 005207.zip in same folder
  • Install SIF Module
  1. Open PowerShell as an administrator.
  2. Set unrestricted execution to current user
Set-ExecutionPolicy -Scope CurrentUser Unrestricted

3. Register repository

Register-PSRepository -Name SitecoreGallery https://sitecore.myget.org/F/sc-powershell/api/v2

4. Install SIF

Install-Module SitecoreInstallFramework

5. After SIF installation check if the SIF 2.3.0 is installed

Get-Module SitecoreInstallFramework –ListAvailable 

To install specific version of SIF or run multiple version of SIF see this blog

  • Install prerequisites before installing XP 10

Switch to the sitecorexp10 folder and execute following script

Install-SitecoreConfiguration -Path .Prerequisites.json
  • Install SOLR 8.4.0

1. Switch to e.g.- sc101_install folder. Open Solr-SingleDeveloper.json file

2. Change the Install Root for SOLR – DefaultValue

 "SolrInstallRoot": {
            "Type": "String",
            "Description": "The file path to install Solr. This config will add the prefix and solr version e.g C:\Solr becomes C:\Solr\[SolrServicePrefix]Solr-8.4.0",
            "DefaultValue": "C:\SOLR"
        },

3. Execute –

Install-SitecoreConfiguration -Path Solr-SingleDeveloper.json

4. Check https://localhost:8983/solr/#/ if SOLR installed on SSL

Prepare and Execute script for installation

Open XP0-SingleDeveloper.ps1 file to update following-

  • $Prefix
  • $SitecoreAdminPassword
  • $SCInstallRoot – change path to the folder installers are available
  • $SolrUrl
  • $SolrRoot
  • $SolrService
  • $SqlServer
  • $SqlAdminUser
  • $SqlAdminPassword

Copy license to the e.g. – sc101_install folder

Execute installation script – .\XP0-SingleDevelor.ps1

Hope the installation completes without any issues

Post Installation activities

Rebuild the search indexes and the Link database
After you install Sitecore Experience Platform, you must rebuild the search indexes and rebuild the Link databases.


To rebuild all the indexes:

  1. On the Sitecore Launchpad, click Control Panel, and in the Indexing section, click Indexing manager.
  2. In the Indexing Manager dialog box, click Select all, and then click Rebuild.

To rebuild the Link databases for the Master and Core databases:

  1. On the Sitecore Launchpad, click Control Panel, and in the Database section, click Rebuild Link Databases.
  2. Select the Master and Core databases and then click Rebuild

Uninstall Sitecore Instance

To uninstall Sitecore instance uncomment the Uninstall command in XP0-SingleDeveloper.ps1 file. Comment the install command-

Errors

“No registration found for extension ‘RemoveSQLDatabase’ of type ‘Task’”

Run

Install-SitecoreConfiguration -Path .Prerequisites.json

OR

Install-Module -Name SQLServer

Hope this helps to install Sitecore XP 10.1 instance

Different approaches to assign Sitecore SXA theme to a site

Once a tenant and site are created and/or a theme is manually created you may want to assign a theme to a site. A theme is automatically assigned when during a site creation but what if you want to assign a theme to already created site.

See this blog to create a tenant and site and different approaches of creating a theme.

Experience Editor

Select any Partial design and open experience editor select Experience Accelerator option.

Select Theme option. Change the theme.

This will also the change the theme in the selected site – /sitecore/content/<<tenant folder>>/<<tenant>>/<<site folder>>/<<site>>/Presentation/Page Designs

Content Editor

To change the theme for a specific site. Navigate to the site/Presentation/Page Designs

for e.g.:- /sitecore/content/<<tenant folder>>/<<tenant>>/<<site folder>>/<<site>>/Presentation/Page Designs

In the Styling section change the Theme field

Hope this helps.

Different approaches of creating Sitecore SXA themes

Themes define the look and feel of a site and makes it flexible to change the layout and design of the website.

Themes help to customize the appearance of the site which includes layout, typography, color and other design elements.

SXA come with two types of themes- Site and Base themes. To add own/custom classes and assets, such as styles, scripts, images and fonts use Site theme.

There are multiple ways site theme cane be created-

Option 1 – Add custom theme when creating a Site

Check out this blog post for adding a theme when creating a site

Option 2 – Add theme to existing Site (create theme manually)

Right click on your site- click Scripts and click New Site Theme option

Provide the theme name and location.

Click OK and a theme should be created on specified location

Option 3 – Add a theme using SXA CLI

Will add the details shortly.

Hope this helps!

Sitecore 10 SXA Site Structure

Previous blog shows how to create Tenant and SXA Site.

In this blog lets see what does the installation script adds to the SXA site.

Following is the site content structure-

1. Site

SXA site is a container to the content that will be used as a output of the site. Site contains the settings to select the Site Media Library, Theme Folder and Modules.

2. Home Page

This is the home page of the site. All other pages in the site must be stored under the Home item.

3. Media Folder

Media Folder helps scope the part of media library is available to content editors on the images selection dialog.

You can change the scope by adding or removing the folder in “Virtual” section “Additional Children” field.

Media Folder “Additional Children” field
Scoped item in media folder from Media Library
Scoped to the selected folders configured in “Additional Children” field

Best Practice – Do not put media items directly under the Media folder. Form SXA 1.7 and higher uploading items to media folder in the Site is not allowed.

4. Data Folder

Data Folder is the repository for storing all the data sources. These data sources can be reused across many pages scoped inside the Site. Data folder had component type folder and can be created manually or when the module is installed.

Data for each component can be created manually from the content tree or from experience editor by using the “Associated Content” option. Data folder is used as a source configured in rendering’s Data Source field in a form of query or directly mapped to the component folder.

Best Practice – Clean up unused data sources

Best Practice – Give Site data sources meaningful names

Best Practice – Organize site data sources in folders

Best Practice –Run source field reports to help set the data source context

5. Presentation

The presentation folder contains all the presentation related details and settings for the components selected while creating the site.

Presentation folder has list of components based on the modules selected while creating the site.

Presentation folder contains Page and Partial Designs, Layout Service , Available Renderings, Rendering Variants and Styles.

Rendering variant contains list of components on the site and can be customized using Variant Definition and Variant Fields. Also can use template based Variant like Scriban and Template

6. Settings

Settings folder contains site specific configuration. Site Grouping contains the Site Settings like site name, host name, database etc.

Settings also contains the Redirects, HTML snippets and Item Queries. Settings Folder contains options to select the Fav icon, error handling and other SEO related settings.

Sitecore 10 SXA-Create a tenant and Site

Tenant Folder

Sitecore supports multitenancy, which means you can have multiple sites running on a single Sitecore instance.

Tenant folder is just a container to hold multiple tenants you may have as a part of site structure. Inherited from _Base Tenant Folder. You may create a tenant folder to hold the multiple tenants of a Company.

A folder with provide tenant folder name is create here – /sitecore/templates/Project/<Tenant Folder Name>

Template Path – /sitecore/templates/Foundation/Experience Accelerator/Multisite/Tenant Folder

Tenant

Tenant is a top-level container for the Sites underneath. Site in same tenant are related, that means they are able to share data and layouts. Creation of tenants comes with optional modules.

Template/sitecore/templates/Project/<<Tenant Folder>>/<<Tenant>>/Tenant

Tenant been created successfully.

Creating Site

Site is a collection of content and output with a common overall business objective sharing a common set of assets

To create site right click on Tenant and select an option to create Site or Site Folder

Site Folder –

Site folder is a container for multiple sites.

Template – /sitecore/templates/Foundation/Experience Accelerator/Multisite/Site Folder

Site

General tab- Provide Site name, host name and Virtual folder. You may keep this as default and change later based on the requirements.

Select the required modules as a part of Site creation.

Create a new theme or select existing. This will e your site theme and can be changed from Page Design –

Template – /sitecore/content/<<tenant folder>>/<<tenant>>/<<site folder>>/<<site>>/Presentation/Page Designs

Select a grid mainly Bootstrap 4

At this point we have SXA site been created-

Remove Site

To remove Site, right click on site, select scripts and Remove Site option.

Sitecore Technology MVP 2021

Voluntarily contributing your time, energy and skills to the community and help customers succeed and be a part of their growth is all that matters. I believe going above and beyond to achieve expertise in whatever you are doing and giving back to community however small it may be is the key to grow together and when these efforts are recognized it inspires the community to continue their good work.

Happy to share that I have been recognized as 2021 Sitecore MVP.

Sitecore recognizes professionals who deliver outstanding customer experiences through shared expertise on Sitecore’s products, the 2021 MVP program draws from a community of 12,000 certified developers and over 20,000 active participants. This year’s 284 MVPs contributed invaluable knowledge to the community in 2020 and demonstrated true mastery of the Sitecore platform to support partners, customers and prospects.

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.

Install Sitecore 10 Update 1 using Install Assistant

Sitecore On Premise deployment with Sitecore Install Assistant user interface guides through the Sitecore XP Developer Workstation(XP Single).

Download the Graphical setup package for XP Single

Download and Install Sql Server 2019 express edition.

Download and Install Sql Server Management Studio-

Restart Machine

Extract Sitecore 10.0.1 rev. 004842 (Setup XP0 Developer Workstation rev. 1.2.1-r1).zip file

Start the setup

Install Sitecore Install Framework (SIF) and Windows pre-requisites

Restart computer. Start the installation again this time you can skip the pre-requisites if already installed

Install SOLR. Provide Solr port and path prefix

After SOLR is installed successfully. Provide the Sitecore solution prefix and license path.

Sitecore settings

Provide SQL Server Settings

Provide Solr installed path and service name.

You may check the service name and the status of the service. Run services.msc.

Optional SXA module to install

Confirm the provided details

Installation Complete

Sitecore Commerce 10 Business Tools- Part 2 – Create custom vertical view component

This is a Part-2 of customizing Sitecore Commerce Business Tools. To see how to setup the environment for customization before you could start creating a custom component see Part-1

Often you have seen entity details are shown in Flat view i.e. horizontally, fields and there values are displayed. If you have too many fields to display flat view doesn’t seem to be user friendly. In this case the best way to display such details will a vertical view.

This post assumes Instance of Commerce Engine deployed in development environment and a custom entity is created. This is just a example on how to extend Business Tools using Angular which shows the flexibility of Business Tools in terms of cusotmization.

I have a entity named Organization and captures details for same which has quite a few properties as seen in below screen-

There are around 10 fields in the details section of the entity. These fields are squeezed and also doesn’t look user friendly. This would go more ugly if there are more fields added in the entity.

Sitecore Entity View default UIHint is Flat where a single row is displayed in a form of table.

This would look better if it is displayed in Vertical View or Form View i.e. each field in a different row.

Lets see how this can be done using BizFx SDK and the development environment we have created in this post – <<ENTER SETUP DEV BUSINESS TOOL ENVIRONMENT LINK HERE>>

Sitecore business tools already have Flat and Table View. Flat been default. Lets create a new view called as Vertical View.

Open the folder where the SDK zip file was extracted and navigate to src/app/components/views folder

View folder should look like this-

Copy paste and rename following files-

  1. Copy and Rename sc-bizfx-flatview.component.css to sc-bizfx-verticalview.component.css
  2. Copy and Rename sc-bizfx-flatview.component.html to sc-bizfx-verticalview.component.html
  3. Copy and Rename sc-bizfx-flatview.component.ts to sc-bizfx-verticalview.component.ts

Open sc-bizfx-verticalview.component.html. Change the table to display the property name and value-

 <table scTable class="mb-0" *ngIf="view.Properties.length">
      <thead>
        <tr>
		<th>Property Name</th>
		<th>Property Value</th>
	</tr>
      </thead>
      <tbody>
		<tr *ngFor="let property of (view.Properties | isNotHidden)">
          <td>{{property.DisplayName}}</td>
		  <td>
            <div [ngSwitch]="property.OriginalType">
              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchCase="'System.DateTimeOffset'" class="property">
                  <div *ngIf="property.UiType === 'FullDateTime'">
                      {{property.Value | date:'short':'':bizFxContext.language}}
                  </div>
                  <div *ngIf="property.UiType !== 'FullDateTime'">
                      {{property.Value | date:'shortDate':'':bizFxContext.language}}
                  </div>
              </div>

              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchCase="'System.Decimal'" class="property">
                {{property.Value | number:'':bizFxContext.language}}
              </div>

              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchCase="'Sitecore.Commerce.Core.Money'" class="property">
                {{property.Value | scCurrency:'code':'1.2-2':bizFxContext.language}}
              </div>

              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchCase="'Html'" class="property">
                <div [innerHTML]="property.Value"></div>
              </div>

              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchCase="'List'" class="property">
                <div *ngFor="let item of getList(property)">
                  {{item}}
                </div>
              </div>

              <div id="property-{{view.Name}}-{{property.Name}}" *ngSwitchDefault class="property">
                {{property.Value}}
              </div>
            </div>
          </td>
        </tr>
      </tbody>
    </table>

Add following to div having childViews loop to sc-bizfx-flatview.component.html-

<sc-bizfx-verticalview *ngIf="childView.UiHint === 'Vertical'" id="verticalView-{{childView.Name}}" [view]="childView"></sc-bizfx-verticalview>

Open sc-bizfx-verticalview.component.ts. Change the @Component and export Class name

@Component({
  selector: 'sc-bizfx-verticalview',
  templateUrl: './sc-bizfx-verticalview.component.html',
  styleUrls: ['./sc-bizfx-verticalview.component.css']
})
export class ScBizFxVerticalViewComponent {
  /**
    * Defines the view
    */
  @Input() view: ScBizFxView;

  /**
    * @ignore
    */
  constructor(
    public bizFxContext: ScBizFxContextService) {
  }

  /**
    * Helper method
    *
    * Parse the value of property with `UiType` of `List`.
    */
  getList(property: ScBizFxProperty) {
    return property.Value != null ? JSON.parse(property.Value) : [];
  }
}

Navigate to components folder. Open index.ts

Add- export * from ‘./views/sc-bizfx-verticalview.component’;

Navigate to app folder. Since a new class is registered this needs to be registered in app.module.ts file.

Open app.module.ts file. Add ScBizFxVerticalViewComponent to App Root import and to the @NgModule – declarations section-

import {
  ScBizFxActionComponent,
  ScBizFxActionBarComponent,
  ScBizFxFlatViewComponent,
  ScBizFxItemViewComponent,
  ScBizFxListPoliciesComponent,
  ScBizFxListViewComponent,
  ScBizFxSearchViewComponent,
  ScBizFxTableViewComponent,
  ScBizFxViewPropertyByTypeComponent,
  ScBizFxViewPropertyByUiComponent,
  ScBizFxViewPropertyTagsComponent,
  ScBizFxActionGridComponent,
  ScBizFxActionPropertyDateTimeComponent,
  ScBizFxActionPropertyTagsComponent,
  ScBizFxActionPropertyComponent,
  ScBizFxAutocompleteComponent,
  ScBizFxBraintreeComponent,
  ScBizFxMediaPickerComponent,
  ScBizFxViewComponent,
  ScBizFxVerticalViewComponent
} from './components';
declarations: [
    AppComponent,
    ScBizFxActionComponent,
    ScBizFxActionBarComponent,
    ScBizFxFlatViewComponent,
    ScBizFxItemViewComponent,
    ScBizFxListPoliciesComponent,
    ScBizFxListViewComponent,
    ScBizFxSearchViewComponent,
    ScBizFxTableViewComponent,
    ScBizFxViewPropertyByTypeComponent,
    ScBizFxViewPropertyByUiComponent,
    ScBizFxViewPropertyTagsComponent,

    ScBizFxActionGridComponent,
    ScBizFxActionPropertyDateTimeComponent,
    ScBizFxActionPropertyTagsComponent,
    ScBizFxActionPropertyComponent,
    ScBizFxAutocompleteComponent,
    ScBizFxBraintreeComponent,
    ScBizFxMediaPickerComponent,
    ScBizFxViewComponent,
    ScBizFxVerticalViewComponent
  ],

That’s all changes required to have a custom component in Business Tools.

Next open PowerShell and build the changes made and run the Business Tools site

ng serve

The site should now listen to 4200 port.

Now lets create/update a entity view with a Vertical view UIHint. I already have entity with the Flat view. I will change the UIHint to “Vertical” to display the properties and there values vertically.

Build and deploy engine changes to Authoring site. (Not covered in this blog)

Using Flat view either squeezes the table or a horizontal scroll which is not user friendly. With the Verticalview Organization details are now shown vertical with the Property Names and Values in different rows.

This view is more readable for user specially with the long text in Address.

Easy to implement and test on development environment you can build more complex controls with the same approach

Next post will see how to deploy these changes to production.

Hope you liked this post.