Create your first plugin

Current version: 9.3

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.

Note

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:

  1. In the Sitecore.Commerce.Engine SDK folder, open the Customer.Sample.Solution.

  2. In Visual Studio, right-click the src folder, click Add, New, Project....

  3. 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)

      Note

      You 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).

    Add New Project dialog box showing the Sitecore.Commerce.Plugin.Sample project template
  4. Click OK. Visual Studio creates a new plugin project folder containing all sample artifacts.

    Visual Studio Solution Explorer showing plugin project folder with sample items
  5. Add the new plugin as a project dependency in the Sitecore.Commerce.Engine project. Expand the Sitecore.Commerce.Engine project, right-click the Dependencies node, click Add Reference, and select the checkbox next to the new plugin, then click Ok.

    Visual Studio Solution Explorer showing Sitecore.Commerce.Engine item tree
  6. Save the solution. When the file is saved, it resolves the dependency and loads it when the application is launched.

  7. 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.

Do you have some feedback for us?

If you have suggestions for improving this article,