In this post, I'll be explaining how you can customize Commerce Engine.
Key Extension Points
Each of the following areas can be extended & customized in Experience Commerce:
- Business Tools is extended using the Commerce Views service
- I did a talk & blog post about this last year. You can read all about it here.
- The Commerce Engine is built on a pluggable extensibility model which allows you to add/remove/modify functionality via plugins.
- Compositional extensibility allows you to extend commerce entities by adding components to an entity.
SXA Storefront provides most commonly used components required for an ecommerce website. These components can be customzed and extended to meet your specific requirements. More on this in another post.
Commerce Engine Plugins
- The Commerce Engine is a light weight .NET core application.
- Functionality is offered through a pluggable extensibility model in the form of plugins.
- All core commerce functionality is also implemented as plugins. This allows you to easily remove or modify bits based on your requrements.
- Commerce Engine services are exposed via an OData api to allow external system including Sitecore to interact with it.
The following plugins come OOTB with Commerce Engine:
Commerce Engine SDK
The XC9 download package contains the Commerce Engine SDK which contains:
- Customer.Sample.Solution: A Visual Studio sln that contains the Commerce Engine and some sample plugins including payments (via Braintree). This is starting point for extension. You can remove sample plugins, updated namespaces, and start adding your own customized plugins.
- Tools for creating plugin scaffolding.
- Postman collection to interact with the Commerce Engine service API.
Structure of a Plugin
This is an example of how a plugin is structured in visual studio:
The key building blocks of a plugin are:
Pipelines & Blocks:
- These are similar to pipelines in Sitecore. Instead of processors, they contain ‘blocks’.
- Blocks contain your implementation
- Unlike Sitecore, pipelines and blocks are configured in code rather than xml.
- Policies are a set of rules that can be used to change the behavior of a plugin.
- Think of them as code based configuration.
- Commands are used to trigger pieces of work, usually executing a pipeline.
- Controllers expose plugin functionality through the Service API.
- They usually execute a command.
- An entity is a business concept that is encapsulated in a POCO class that inherits from the Commerce Entity base class.
- It is persisted to the database as serialized JSON with a unique identifier associated to it.
- Entities can be extending by adding Components.
- Components are simply classes that are injected into the entity by a plugin through a Pipeline Block.
Plugin initialization is the glue that binds everything together. You do this by configuring services:
- Add/remove pipelines
- Configure blocks for new pipelines
- Add/remove blocks to/from existing pipelines
You should now be in a good position to start impelementing your customized requirements in the Commerce Engine. Stay tuned for more- in the last post of this series, I'll be going through the commerce service API.