Registering a Plugin in SXC

I've mentioned previously that you need to add a reference to a plugin dll in the Commerce Engine project, but that won't return plugin information as part of the OData metadata, for that to happen we need to add a new block to the IRunningPluginsPipeline pipeline that will load our assembly information.

public class RegisteredPluginBlock : PipelineBlock<IEnumerable<RegisteredPluginModel>, IEnumerable<RegisteredPluginModel>, CommercePipelineExecutionContext>
    public override Task<IEnumerable<RegisteredPluginModel>> Run(IEnumerable<RegisteredPluginModel> arg, CommercePipelineExecutionContext context)
        if (arg == null)
            return Task.FromResult((IEnumerable<RegisteredPluginModel>)null);

        var plugins = arg.ToList();
        PluginHelper.RegisterPlugin(this, plugins);

        return Task.FromResult(plugins.AsEnumerable());

We can add the block to our pipeline in the ConfigureSitecore.cs file

services.Sitecore().Pipelines(config => config
    .ConfigurePipeline<IRunningPluginsPipeline>(configure => configure.Add<RegisteredPluginBlock>().After<RunningPluginsBlock>())