Create your first plugin
This topic describes the steps you perform to create your first Commerce Engine plugin using the Customer.Sample.Solution
that is included as part of the Sitecore.Commerce.Engine.SDK
.
Before you start, you should complete this procedure as a prerequisite, to make sure that you have installed the Sitecore.Commerce.Plugin.Sample
template in Visual Studio, and that you have a working Customer.Sample.Solution
.
The screen grabs in this procedure show Visual Studio 2017 but the steps themselves are the same for Visual Studio 2019. For information on the compatibility of Sitecore XC with browsers, operating systems, .NET frameworks, and database servers, see the Sitecore compatibility table.
To create your first plugin:
-
In the
Sitecore.Commerce.Engine SDK
folder, open theCustomer.Sample.Solution
. -
In Visual Studio, right-click the
src
folder, click Add, New, Project.... -
In the Add New Project dialog, click the Sitecore.Commerce.Plugin.Sample Visual C# project template, and then provide the Visual Studio project settings, for example:
-
Name: Plugin.Sample.Loyalty
-
Location: path to the Solution's
src
folder (\Sitecore.Commerce.Engine.SDK\<Solution>\src
)NoteYou should not add your custom Commerce Engine plugin to a folder outside of the
Sitecore.Commerce.Engine.SDK
folder, as the file paths can conflict with the build process. -
Framework: .Net Framework (or another supported version of the .Net Framework).
-
-
Click OK. Visual Studio creates a new plugin project folder containing all sample artifacts.
-
Add the new plugin as a project dependency in the
Sitecore.Commerce.Engine
project. Expand theSitecore.Commerce.Engine
project, right-click the Dependencies node, click Add Reference, and select the checkbox next to the new plugin, then click Ok. -
Save the solution. When the file is saved, it resolves the dependency and loads it when the application is launched.
-
Build the solution.
The project folder that the Sitecore.Commerce.Plugin.Sample
template creates in Visual Studio contains a complete, end-to-end sample project, that shows an extension from the controller level all the way through running a pipeline. In many cases, you will not need to create a new pipeline, but instead want to extend an existing pipeline to add new processing blocks. You can delete the samples that are not required in your project, but we recommend that you keep them until you are sure that you don't need them. You can copy and paste a sample item to create new ones, such as components, for example. The sample items contain all the necessary elements and structure. You can then change the naming of the item to your preferred pattern.