Last Updated on January 30, 2021 by sandeeppote

In my previous post we saw the first step to create a new plugin by adding a new plugin project to the solution, restoring the correct binaries and reference new plugin to the Engine project.

In this post I will share what comes with the Plugin project template.

Sitecore Commerce Plugin project template creates folders and classes which helps to quick start creating a plugin, lets see what are these files –

1. Commands

To my understanding command is unit of work to perform set of actions. Commands allows to execute a pipeline and blocks within a transaction scope. Create a custom command by inheriting from CommerceCommand class. Use PerformTransaction method to run a pipeline in a transaction scope.

2. Components

If you want to extend existing or custom entities, use component. Component has attributes that support entities.

3. Controllers –

Controllers expose commerce functionality implemented in plugins. They are the api endpoints. Sitecore Commerce has various Controller type- Entity, Api, Devops and Command. Create your own controllers by inheriting from CommerceController

4. Entities-

They are the persistable unit and represent the business concept. Inherited from the CommerceEntity they has a unique identifier that helps to retrieve the entity by using a Entity controller type.

5. Models –

They are the POCO classes that are reusable in entities and components. Can be used to present data as part of command response .

6. Pipelines – They do the heavy lifting in plugin by making it possible to define the extensible behavior. Create your own pipeline and add blocks you want to execute to implement your business logic. Blocks within pipelines execute in a sequence they are registered.

7. Policies

Policies defines behavior for the functionality provided by the plugin. Its is recommended to not extend or inherit out-of-box plugins instead create your own. Plugins can be changed or created new by updating the JSON files provided in environment folder of the various roles site.

ConfigureSitecore

ConfigureSitecore class helps to register the pipeline and block definitions that a plugin defines. You can create a new plugin and AddPipeline or extend the existing pipeline by adding a block After or Before any existing blocks. ConfigureSitecore class registers pipelines every time engine loads. You can also register commands or register your custom class in this class.

ConfigureServiceApiBlock

This registers customer entities, components and controller action with ODATA model. It allows to these elements to be used when a REST API call is made and available when generating a proxy.