Extending Pipelines
Modify system behavior by modifying Pipelines.
Ucommerce Pipelines are the primary extension points where you can execute any custom logic to fit your requirements. These extensions could be changing the existing behavior of the pipelines, adding new steps to be executed, and integrating with other systems.
Implementing a Task
Before implementing a new Pipeline Task, we must identify which pipeline we want to extend, specifically the input and output parameter types. In the examples below, we'll use XPipelineInput and XPipelineOutput to signify the types, as they follow the naming convention of the Pipeline name followed by Input or Output.
Create a new Class.
Inherit from
IPipelineTask<XPipelineInput, XPipelineOutput>
Implement the Execute method.
Context.Input contains information passed to the Pipeline when it is being executed.
Context.Output contains information that will be returned once the Pipeline is finished executing.
A Pipeline will save changes in the current database context as the last task. Any tracked entity changes will be saved.
Adding a Task
The next step is registering the PipelineTask in the IoC container for the proper Pipeline and position. This can be done via the Ucommerce builder, and it is recommended to use a helper method for reusability and clarity.
Extension method example
This example displays different ways of modifying a pipeline.
Replace tasks by placing yours before or after the default task, then remove the default task.
Register your custom pipeline tasks, using an extension method
Now you can register all of your customized pipeline tasks using your extension method like this.
When adding custom tasks, remember to do it after adding all of the Ucommerce components. This way, you can be sure that your custom logic is added in the desired order and registered correctly.
Last updated