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.
- Entity Views
- 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 to Setup development environment for Sitecore Commerce 9.3 Engine
Step 2 – Install Visual Studio plugin Extension
- Go to the solution root folder or SDK folder and run the Sitecore.Commerce.Plugin.vsix file. Close the Visual Studio solution if open.
- This should install the 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
- Build the project.
Step 4 – Reference project and run engine
- Add a 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 is the first step towards the journey of extending 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.
Hope you enjoyed this post. Stay tuned.