Creating and using a custom Sitecore command involves several steps. Here’s a step-by-step guide to help you through the process.

Step 1

Create a class which inherits below class

Copy to Clipboard

Step 2:

Create a patch file (Foundation.Sync.config) in the App_Config/Include/Foundation folder to register the new command in Sitecore.

Copy to Clipboard

Step 3:

Open Core Database and navigate to the /sitecore/content/Applications/Content Editor/Ribbons/Chunks.

Create a new item using the /sitecore/templates/System/Ribbon/Chunk template.

Under the Chunk You can crate multiple Ribben button with using

/sitecore/templates/System/Ribbon/Large Button Template

It’s look like below:

On the Click Filed write command name that we have given in the config patch file.

Create on Strips under

/sitecore/content/Applications/Content Editor/Ribbons/Strips

With using /sitecore/templates/System/Ribbon/Strip Template

Give a name SV Commerce
Under the SV Commerce add one more item with /sitecore/templates/System/Reference Template Give name : Sv Commerce

In the reference field select the chunk.

Once you have done the above process you can see a new ribbon tab on the sitecore menu bar. If it’s not visible right-click on the menu bar and select for visibility you can found newly created button out there.

By clicking on the button it will call your command and finish the process.

Additional Considerations:

  • Sitecore.Commands.config:After creating your command (either via template or code), you’ll need to register it in the Sitecore.Commands.config file located in the App_Config/Sitecore/CMS.Core folder. This file maps the command name defined in your template or class to its actual implementation.
  • Security: Ensure your commands are properly secured to prevent unauthorized access. Utilize Sitecore security mechanisms like roles and permissions to control who can execute specific commands.
Here are some resources for further exploration:

Sitecore Documentation on Command Templates:

How to Create Custom Command in Sitecore CMS?

Sitecore.Commands.config File:

email subscribe image

Subscribe to our Newsletter and Dive into Exclusive Content!