I am new to Sitecore commerce Minions.
I wanted to create a Minion which runs for every 30 minutes to update the Product values.
I am getting the Products properties from external source.
What changes do I need to make ?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this communityFirst of all you need to declare your minion on the environment definition for your minions environment.
In the Sitecore.Commerce.Engine project is the JSON file PlugIn.Habitat.CommerceMinions-1.0.0.json which is the definition for the habitat minions environment. This is the active environment on the commerce minions web site (one of 4 in IIS installed as part of commerce).
First of all you need to declare your minion in a json :
{
"$type": "Sitecore.Commerce.Core.MinionPolicy, Sitecore.Commerce.Core",
"WakeupInterval": "00:05:00",
"ListToWatch": "",
"FullyQualifiedName": "Plugin.MyProject.Import.ImportMinion, Plugin.MyProject.Import",
"ItemsPerBatch": 10,
"SleepBetweenBatches": 500
}
You need to declare your class which inherits from Minion class
namespace Plugin.MyProject.Import
{
public class ImportMinion : Minion
{
protected IImportMinionMinionPipeline MinionPipeline { get; set; }
public override void Initialize(IServiceProvider serviceProvider, ILogger logger, MinionPolicy policy, CommerceEnvironment environment, CommerceContext globalContext)
{
base.Initialize(serviceProvider, logger, policy, environment, globalContext);
MinionPipeline = serviceProvider.GetService<IImportMinionMinionPipeline>();
}
public override async Task<MinionRunResultsModel> Run()
{
this.Logger.LogInformation("ImportMinion running");
var commerceContext = new CommerceContext(this.Logger, this.MinionContext.TelemetryClient, null);
commerceContext.Environment = this.Environment;
CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);
MinionRunResultsModel res = await this.MinionPipeline.Run(new MinionRunResultsModel(), executionContextOptions);
return new MinionRunResultsModel();
}
}
}
Because of the changes in the json files you need to bootrastrap your commerce engine.
Please have a look for more informations on next links :
https://blog.ryanbailey.co.nz/2018/03/sitecore-experience-commerce-creating.html https://blog.ryanbailey.co.nz/2018/05/sitecore-experience-commerce-minion-to.html https://github.com/commerceengineplugins/sampleminion