Getting Started with Sitecore Commerce

Recently, I got a chance to look at Sitecore Commerce. So, i will be sharing my understanding after self learning and looking into real world project of commerce for few weeks. I hope this will be helpful for those wanted to get started on commerce.

Getting Started with Commerce

Roles

Along with standard XM/XP roles, there are few other roles created with commerce installation. They are:

  • SitecoreBizFx: Sitecore Business Tools – In simple words, admin panel for managing all features like Customers, Prices and Promotions, Inventory, Orders etc. It’s data driven applications built on Angular and Knockout. You will find config.json in SitecoreBizFx role which will have important configurations to connect to identity server and commerce engine.
    2019-08-11 14_25_13-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1
  • Engine Roles
    There are different kind of commerce engine roles being created when you install commerce. They share many similarities thus it’s important to understand what each role is responsible for.

    • Ops: The Ops role is an instance of the Commerce Engine that is internal and only available to DevOps personnel. This role can have an identity with higher privileges allowing DevOps personnel to perform maintenance tasks that are not permitted to other roles (e.g., bootstrapping and environment initialization functions).
      Untitled
      For more information on setting up postman for Sitecore commerce API calls:

    • Authoring: The Authoring role is the instance of the Commerce Engine that serves traffic from the Commerce business tools. For ex: Merchandising experience for managing Pricing and Promotions, CSR Experience for managing  Customers and Orders. Since this role serves lighter traffic (i.e., eCommerce solutions have relatively few business users compared to the number of shoppers), scale requirements are normally relatively low. As this role is being used by business tools means SitecoreBizFx role as mentioned above, you will find “EngineUri”: “https://localhost:5000” configuration in config.json of SitecoreBizFx role.
      2019-08-11 14_47_32-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1
    • Shops: The Shops role is the instance of the Commerce Engine that serves traffic from one or more storefronts. This role is intended to scale to support demand, and is usually installed in close proximity to the Sitecore Experience Platform instances that generate the traffic. To scale the solution, the Sitecore XP instances and/or the Commerce Engine instances can be scaled depending on traffic mix and the location of any bottlenecks. Shops role which is connected to CD role is generally responsible for services like Shopping cart services, Order services, Customer Self Service etc.
      2019-08-11 14_58_11-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1
      You can see the configuration in your web role from config \App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config.
      2019-08-11 15_30_02-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1
      But we couldn’t find https://localhost:5005/ which is shop role in any of configuration in standard installation (also mentioned in https://hachweb.wordpress.com/2018/08/06/sitecore-xc-9-0-2-commerce-environments-behind-the-scenes/).
      Scaled: For scaled XP environment where you will have separate CM and CD, shopServiceUrl will point to authoring role in CM while in CD it will be pointed to shops role.
      You can find scripts written by our community members for scaled XC installation here.
      Deploy-Sitecore-Commerce-SitecorePackagesCD.ps1
      2019-08-11 15_36_34-Sitecore-Commerce-v902-Scaled-Installation_Deploy-Sitecore-Commerce-SitecorePack
    • Minions: The Minions role is an instance of the Commerce Engine that runs independently and supports asynchronous processing. This includes any post-order capture processing as well as any cleanup or pruning.
      2019-08-11 15_44_30-Microsoft Edge
      Minion role is not connected directly to any of role like Web, Authoring, Shops etc. It is just connected to commerce database directly.

Storefront

SXA Storefront is a framework that enables you to create a shop experience easily and quickly. SXA Storefront is built on top of Sitecore Experience Accelerator along with many commerce specific components.

It uses all core feature of SXA like page designs, partial designs, renderings, renderings variants etc.

When you install commerce, by default it installs a storefront site for you. And if you want to create it yourself the you can create it same as normal SXA site by clicking on tenant and adding new site through create site dialog.

Modules
2019-08-11 17_05_15-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1
Here, you can find three modules specific to commerce.
Commerce Storefront Components:  provides the SXA Toolbox renderings and Sitecore Commerce Control Panel. With this checked, you will see additional commerce specific renderings in toolbox:
15d35bc616ed73
To understand more about each sections and renderings into each sections visit Commerce Account renderings, Commerce Cart renderings, Commerce Catalog renderings, Commerce Checkout renderings, Commerce Orders renderings, Commerce Shared renderings, and Commerce meta renderings
Commerce Storefront Template: provides storefront templates and pages. For ex: Shopping cart, Checkout, Account pages etc. And also it comes with default partial designs and page designs for different kind of pages.
page designs

Page design and partial design relation
page-partial designs
Commerce Storefront Habitat Catalog: provides a sample catalog with categories and sellable items.

Note: There are few changes related to catalog since Commerce 9.0.2. They are:

  • The default Catalog and Start Navigation Category are now configured from under “{site}/settings/commerce/catalog configuration”. This is in order to avoid references from the Global Control Panel settings to specific sites after the catalog content has been moved under the specific sites where it belongs. The old location under Commerce Control Panel is still supported to provide backward compatibility.
  • Catalogs are now incorporated into the content area of the storefront sites and reside under a new “{tenant}/{site}/{home}/catalogs” item where it’s used and belongs. This fixes multiple issues including:
    1. Limited access to the catalog for non-admin Sitecore users.
    2. The same products appearing in multiple locations in content with the same item ID and path, causing problems in different places.
    3. Not being able to set and store Sitecore specific settings and data like personalization, presentation and workflow on catalog items and have it persisted correctly and uniquely.

Theme
2019-08-11 17_29_47-NEW-LIXIL-VM (Lixil - Sc9.0.2 installed) [Running] - Oracle VM VirtualBox _ 1

While creating a new site, we can create our own theme for commerce storefront. Storefront Branded is a sample storefront theme which you can use as an example or base when creating theme for your newly storefront.

Commerce Base Themes: Prior to the 9.0.3 release of Sitecore, JavaScript for commerce functionality was loaded using the AssetService pipeline (processor Sitecore.Comerce.XA.Foundation.Common.Pipelines.AssetService.AddJavascript).

To improve performance and multi-site extensibility, all JavaScripts supporting commerce business functionality have been moved from files on disk to the sitecore/Media Library/Base Themes folder.
15d4d5317092e9

  • Commerce Core Libraries: This theme contains the third-party libraries used by Storefront components (such as KnockoutJS, jQuery, Bootstrap, and so on) Knockout is the main framework used in SXA Storefront for data binding.
  • Commerce Services Theme: This theme contains the shared services used by all Storefront components (such as the Ajax service used to handle the Ajax calls to the API). This theme also contains the communication and messaging logic between the components that follow the publisher-subscriber pattern.
  • Commerce Core Theme: This is the Foundation layer that contains the common JS logic used by all the components. It contains the application logic, component definition, and initialization.
  • Commerce Main Theme: This theme contains the main.js file that represents the entry point to the Storefront front-end application initialization.
  • Commerce Components Theme: This theme represents the Feature layer and it contains all the component-specific logic. Each Storefront component has its own JavaScript file named after the component that handles its initialization, data bindings, and some of the interactions between the user and the component.

Plugin

The Commerce Engine delivers commerce functionality through an extensible, pluggable framework. A plugin is an independently publishable extension to the Commerce Engine.

Your commerce solution with plugin may look something like:
2019-08-11 23_50_20-Training - Microsoft Visual Studio

Sitecore.Commerce.Engine: This is the main project of your commerce solution built on .Net Core framework. All the Plugins being created and added into solution will be referenced into this project. All projects from Feature.SDK folder are plugins. Sitecore.Commerce.Engine project also contains different JSON configurations and Policy files. Sitecore.Commerce.Engine project gets deployed to all commerce engine roles mentioned earlier in this post.

There are already few good posts written by community members. You can go through those to understand more about plugin architecture.

Click here to know more about Plugin

Click here for instructions on creating your first Plugin

Click here for getting the customer sample solution up and running

Click here to understand all entities which comes together and forms a complete Plugin

Click here to understand how to remove sample plugins from customer sample solutions and start with fresh solution for your project

Service Proxy: As we know now, data is being exchanged using OData protocol. And as per Helix guidelines and Commerce architecture, we created plugin and it’s endpoints with implementation in .Net Core project while we creates normal MVC project for our feature. Now, if we need to reference such endpoints and models which we created into plugin in feature project, we cannot reference .Net Core project into feature. That is where Proxy comes into the picture.

Click here to know more about what is service proxy

Click here to understand how service proxy works

Click here to know how to generate service proxy with latest OData package

 

 

 

Advertisements

Sitecore Habitat Home installation – Build Error & PackageReference

Currently, i am starting a new project which is based on eCommerce solution build in legacy .net platform which i need to move to Sitecore. I wanted to have a look at all the solutions & structures available in community like Habitat, Sitecore Commerce 9.0.2 (A storefront example with the help of SXA), Habitat Home Demo.

I have already configured Habitat solution many times in local or on server without visual studio installed. I also installed Sitecore Commerce 9.0.2 with the help of installation guide provided by Sitecore and an excellent blog by @viet_hoang_sc: https://buoctrenmay.com/2018/03/09/step-by-step-guide-for-sitecore-commerce-9-installation-on-your-machine/ . Now, it was turn for Habitat Home Demo.

Continue reading “Sitecore Habitat Home installation – Build Error & PackageReference”