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-
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 –
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
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 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.
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.
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.
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 2 – Install Visual Studio Extension for creating plugin
Go to solution root folder or SDK folder and run the Sitecore.Commerce.Plugin.vsix file. Close the Visual Studio solution if open.
This should install extension on selected Visual Studio Version
Step 3 – Create a plugin
Open your solution. Create a Feature solution folder, just to follow Helix best practice. Right click solution folder to create a new project
Search Sitecore.Commerce.Plugin. Select project type and click next.
Give the project name, location and select .Net Framework 4.7.1. Create a Project.
Sample Folder and Files for Commands, Components, Controller etc shall be added.
Update the Sitecore Commerce Core from 5.0.0 to 5.0.4
4. Build the project. There shouldn’t be any reason the build should fail.
Step 4 – Reference project and run engine
Add Plugin project reference to your Commerce.Engine Project
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.
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.
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
Copy the downloaded SDK Sitecore.Commerce.Engine.SDK.5.0.76.zip on your development folder.
Change the debug profile to “Engine” instead of “IIS Express”
In IIS stop Authoring site. i.e. for your default instance it might be CommerceAuthoring_sc930 site
Run the Engine from Visual Studio. This will open the console.
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.
And here we have business tool sending request to engine running on Visual Studio, see GetNavigationView() been called in console-
Ctrl + T – Find anything in Visual Studio Solution
Fastest way to find files in your visual studio solution. Press this shortcut and start typing the keyword to navigate to your desired file.
Ctrl E + C – Code Cleanup
Ctrl R + R – Rename
The Rename refactoring allows you to rename any symbol, including: namespaces, types, methods, parameters, local variables, properties, fields, and events. It automatically finds and corrects all references to the symbol. The Rename refactoring can be invoked directly from the editor and sometimes from other views (Class View, Object Browser).
Ctrl + Alt + D – Todo explorer
Although nobody likes tech debt but there are instances when on an agile projects few tasks are to be pushed back to the future sprint. In such cases a TODO comments are applied. Re-sharper gives a feature to view such TODO items and a best practice its good to fix the TODO items before a production code is ready. Please this shortcut to view all the TODO items in your solution/project
Alt + Enter + Enter
Shortcut helps to rename the file same as the class name. These instances might come after the file (e.g.: .cs) is created and you decide to change the
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.
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
The product listing and details page should be shown.
Whilst installing Sitecore 9.3 received following error-
Install-SitecoreConfiguration -Path .\prerequisites.json
Install-SitecoreConfiguration : The 'Install-SitecoreConfiguration' command was found in the module
'SitecoreInstallFramework', but the module could not be loaded. For more information, run 'Import-Module
At line:1 char:1
+ Install-SitecoreConfiguration -Path .\prerequisites.json
+ CategoryInfo : ObjectNotFound: (Install-SitecoreConfiguration:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
To resolve this issue, you need to set execution policy to your machine-
Set-ExecutionPolicy -ExecutionPolicy AllSigned
You may also provide a scope to the current powershell session-
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.
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
Promotion dashboard shows all Promotion Book where all the Promotions are kept. Dashboard allows to add new Promo book.
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.