Extending the Commerce Engine

Current version: 9.2

The Commerce Engine implements and delivers commerce features and functionality using a plugin framework that enables extensive customization of commerce functionality. The plugin model builds on the principle of composition programming that promotes upgradability, extensibility, and to ensure a clear separation of concerns between individual extensions.

Plugins are the primary means for customizing Commerce Engine functionality to meet the needs of an e-commerce solution. You do not modify the default Commerce Engine plugins. Instead, you create your own custom Commerce plugins to:

  • Extend or modify existing functionality

  • Add new functionality

  • Remove unwanted functionality

Note

For information on the compatibility of Sitecore XC with browsers, operating systems, .NET frameworks, and database servers, see the Sitecore compatibility table.

Best practices for creating custom plugins

The following are recommendations and guidelines that you should consider when developing custom Commerce Engine functionality:

  • As a general rule, you should avoid inheriting from base classes that default plugins contribute. Use a composition programming approach instead.

  • Create your own plugins to implement custom e-commerce functionality and behaviors. You should never alter the source code of default Commerce Engine plugins. Altering the source code of default Sitecore XC plugins can affect your ability to upgrade to a new version of Sitecore XC, and could render your Commerce solution unstable or malfunctioning.

  • A commerce entity cannot have multiple components of a same type. When you create a plugin that contributes a custom component to an existing commerce entity, you should make sure that the same component does not already exist for that commerce entity. For example, the Carts.cs entity (part of the default Sitecore.Commerce.Plugin.Carts) contains a CartLineComponent. Therefore, your custom plugin should not include a component of type CartLineComponent.

Obtaining plugins

You can obtain the officially released and supported versions of Commerce Engine plugins from the Official Sitecore Commerce public NuGet Feed. This enables publishing new versions of the Commerce plugins without the overhead of a major release.

Sitecore partners can also provide plugins as part of custom development.

Workflow for extending the Commerce Engine

You extend the Commerce Engine using Sitecore Commerce Engine SDK, which contains the Customer.Sample.Solution. You can open the Customer.Sample.Solution in Visual Studio. The SDK contains the Commerce Engine project itself, and some sample plugins that demonstrate a typical extension of the solution.

At a high level, when you extend the Sitecore XC solution, you:

  1. Open the Customer.Sample.Solution.

  2. Rename the solution to something more appropriate for your needs.

  3. Rebuild the solution to ensure that the initial solution runs.

  4. Exercise the solution through the Postman samples or using the sample Console app.

  5. Extend the solution by creating additional plugins as separate projects within the solution using a strong separation of concerns.

  6. Test your plugin using a combination of unit tests and functional tests.

  7. When the solution meets requirements, create a new deployment for the solution.

  8. Send the new deployment through any QA or DevOps process to deploy to production.

Do you have some feedback for us?

If you have suggestions for improving this article,