Goal > Our plan is to create a custom command and call that command through postman.
Task Requirements > My manager asked me to add a component in the cart line item.
I have created a project in our plugin solution. By the way, we have completed different solution for plugin and our MVC project. My project name is “Products.Plugin.Cart” which is added to “Sitecore.Commerce.Engine” already.
Step 1 > Create custom component.
I have a folder called Components in my custom plugin project. This ProductId and Unitprice, we are going to send their party. We have no other option except adding them in the Cart line item.
Please check the code snippet for my custom component. You can see in the below code that I have inherited from “Component” which is very important to do.
Step 2 > Create command.
Now, we are creating custom command. Please check the code below –. Please notice that I have inherited from CommerceCommand
Step 3 > Create Controller
The base class is CommerceController
Step 4 > Register OData API method
We also need to register our new OData API method by creating custom pipeline block.
Step 5 > test
Now. You should see this component available in all cartline component. Code snippet to get the
You can also read the article at https://mehedi4055.wordpress.com/2020/02/21/extend-sitecore-9-commerce-api-with-custom-commands/
For more Sitecore related articles follow my blog https://mehedi4055.wordpress.com/
If you would like to take a peek for installing solr for sitecore. Click here!