How to add a new action in the promotions view dropdown menu?

  • Twitter
  • LinkedIn

How to add a new action in the promotions view dropdown menu?

Promotions: add a new action in the dropdown menu of a view

This blog explains the steps to approach and solve a problem when having very few online resources or basic familiarity about the solution. For that, I will propose a problem statement: Add a new option in the dropdown menu of a view that would sync a promotion to a sellable item in the merchandising dashboard.

The very first step that I took after coming across this problem was of course to google out the relevant articles or blogs that might give me a right start or point me in the right direction, but I couldn t find much.

So, I started thinking about this problem and writing down the very step that would be needed to introduce this new option in the menu.

Given fact:

We will have to use Entity Views and Actions API to meet this requirement as the new option must be added to an existing view s actions.

Step 1:

Create a class that would populate this new action on the existing view.

Code:

[PipelineDisplayName(PromotionConstants.Pipelines.Blocks.PopulateSyncPromotionToMerchandisingViewActionsBlock)]
	public class PopulateSyncPromotionToMerchandisingViewActionsBlock : PipelineBlock

Now that the option populates in the dropdown menu the next step is to meet the 2nd requirement where a form should open with a comment box.

Step 2:

Create a new view and add properties to it.

Code:

[PipelineDisplayName(PromotionConstants.Pipelines.Blocks.GetSyncPromotionToMerchandisingViewBlock)]
	public class GetSyncPromotionToMerchandisingViewBlock : PipelineBlock

The third requirement states that when ticking the check icon, the promotion should be synced to the sellable item in the Merchandising dashboard.

Step 3:

When ticking the check icon, we must create a class that would execute a command and run the sync pipeline.

Code:

public class DoActionSyncPromotionToMerchandisingPipelineBlock :
	PipelineBlock

Final Step:

At this point, the command runs the sync pipeline to sync the promotion to merchandising dashboard.

Code:

public class SyncPromotionToMerchandisingCommand: PromotionsCommerceCommand
	{
		private readonly ISyncPromotionToMerchandisingPipeline _syncPromotionToMerchandisingPipeline;

		public SyncPromotionToMerchandisingCommand(
		  ISyncPromotionToMerchandisingPipeline syncPromotionsToMerchandisingPipeline,
		  IFindEntityPipeline findEntityPipeline,
		  IServiceProvider serviceProvider)
		  : base(findEntityPipeline, serviceProvider)
		{
			this._syncPromotionToMerchandisingPipeline = syncPromotionsToMerchandisingPipeline;
		}

		public virtual async Task

Don t forget to add below in ConfigureSitecore class:

.ConfigurePipeline(c =>

? {

? c.Add().After();

? })

? .ConfigurePipeline(c =>

? {

? c.Add().After();

? })

? .ConfigurePipeline(c =>

? {

? c.Add();

? })

Hope this blog was helpful.

Related Blogs

Latest Blogs