How to refer to types declared in other plugins
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I have been following Akshay's video tutorials about SXC, the last one about creating a minion: https://www.konabos.com/blog/creating-a-minion-for-sitecore-commerce-xc-9/. In this tutorial he creates a Plugin with a minion that calculates loyalty points for customers based on previous orders by that customer. In the plugin he refers to multiple types that are found in other plugins, e.g. Order
, Customer
, LoyaltyComponent
(the latter type was created in another custom plugin in a previous tutorial).
How do I set up the dependencies to these types from my new minion plugin?
Or in general:
How do I refer to types that are declared in other commerce engine plugins (features)?
First thought was simply to refer to the other plugins directly, e.g. Sitecore.Commerce.Plugin.Orders
, Sitecore.Commerce.Plugin.Customers
, Plugin.Xxxx.Loyalty
but as the plugins are found in the feature-layer, I guess this is the wrong way to go, otherwise I would have features referencing each other.
Second thought was to refer to the Sitecore.Commerce.ServiceProxy
foundation project that is part of the commerce SDK. This proxy contains the types, deferred from the Commerce Engine API. The problem here is that the types of the ServiceProxy-project do not inherit from the base types found in Sitecore.Commerce.Core
so they are not directly usable with core functionality.
An example: In this method in my pipeline block I am trying to convert the order entities from a list to an object of type Order
, but it is not possible because Order
from the ServiceProxy project does not inherit from Sitecore.Commerce.Core.CommerceEntity
.
public override async Task<Customer> Run(Customer customer, CommercePipelineExecutionContext context)
var listName = $"Orders.ByCustomer-customer.Id";
var result = await _findEntitiesInListPipeline.Run(new FindEntitiesInListArgument(typeof(Order), listName, 0,int.MaxValue), context);
var customerOrderPoints = 0;
if (result?.List != null && result.List.Items.Any())
foreach (CommerceEntity entity in result.List.Items)
var order = (Order)entity; // <-- This is not possible because 'Order' is from ServiceProxy and inherits from another 'CommerceEntity' than the one found in Sitecore.Commerce.Core
if (order != null)
customerOrderPoints += order.HasComponent<LoyaltyComponent>()
? order.GetComponent<LoyaltyComponent>().PointsEarned
: 0;
var loyaltyComponent = customer.GetComponent<LoyaltyComponent>();
loyaltyComponent.PointsEarned = customerOrderPoints;
await _persistEntityPipeline.Run(new PersistEntityArgument(customer), context);
return customer;
So I can only make it work with the first approach but I don't want to go that way. Akshay's code is not on Github yet, so I can't see exactly how he has done.
EDIT: I noticed that the developer's guide for SXC 9 says
A plugin can also take a dependency on another plugin to extend its functionality.
This implies that it is okay to make direct references. But the Helix principles says that one feature module must never depend on another feature module, so perhaps the plugins should not be placed in the feature-layer like they are in this tutorial(?)
sitecore-commerce commerce-engine
add a comment |Â
up vote
5
down vote
favorite
I have been following Akshay's video tutorials about SXC, the last one about creating a minion: https://www.konabos.com/blog/creating-a-minion-for-sitecore-commerce-xc-9/. In this tutorial he creates a Plugin with a minion that calculates loyalty points for customers based on previous orders by that customer. In the plugin he refers to multiple types that are found in other plugins, e.g. Order
, Customer
, LoyaltyComponent
(the latter type was created in another custom plugin in a previous tutorial).
How do I set up the dependencies to these types from my new minion plugin?
Or in general:
How do I refer to types that are declared in other commerce engine plugins (features)?
First thought was simply to refer to the other plugins directly, e.g. Sitecore.Commerce.Plugin.Orders
, Sitecore.Commerce.Plugin.Customers
, Plugin.Xxxx.Loyalty
but as the plugins are found in the feature-layer, I guess this is the wrong way to go, otherwise I would have features referencing each other.
Second thought was to refer to the Sitecore.Commerce.ServiceProxy
foundation project that is part of the commerce SDK. This proxy contains the types, deferred from the Commerce Engine API. The problem here is that the types of the ServiceProxy-project do not inherit from the base types found in Sitecore.Commerce.Core
so they are not directly usable with core functionality.
An example: In this method in my pipeline block I am trying to convert the order entities from a list to an object of type Order
, but it is not possible because Order
from the ServiceProxy project does not inherit from Sitecore.Commerce.Core.CommerceEntity
.
public override async Task<Customer> Run(Customer customer, CommercePipelineExecutionContext context)
var listName = $"Orders.ByCustomer-customer.Id";
var result = await _findEntitiesInListPipeline.Run(new FindEntitiesInListArgument(typeof(Order), listName, 0,int.MaxValue), context);
var customerOrderPoints = 0;
if (result?.List != null && result.List.Items.Any())
foreach (CommerceEntity entity in result.List.Items)
var order = (Order)entity; // <-- This is not possible because 'Order' is from ServiceProxy and inherits from another 'CommerceEntity' than the one found in Sitecore.Commerce.Core
if (order != null)
customerOrderPoints += order.HasComponent<LoyaltyComponent>()
? order.GetComponent<LoyaltyComponent>().PointsEarned
: 0;
var loyaltyComponent = customer.GetComponent<LoyaltyComponent>();
loyaltyComponent.PointsEarned = customerOrderPoints;
await _persistEntityPipeline.Run(new PersistEntityArgument(customer), context);
return customer;
So I can only make it work with the first approach but I don't want to go that way. Akshay's code is not on Github yet, so I can't see exactly how he has done.
EDIT: I noticed that the developer's guide for SXC 9 says
A plugin can also take a dependency on another plugin to extend its functionality.
This implies that it is okay to make direct references. But the Helix principles says that one feature module must never depend on another feature module, so perhaps the plugins should not be placed in the feature-layer like they are in this tutorial(?)
sitecore-commerce commerce-engine
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I have been following Akshay's video tutorials about SXC, the last one about creating a minion: https://www.konabos.com/blog/creating-a-minion-for-sitecore-commerce-xc-9/. In this tutorial he creates a Plugin with a minion that calculates loyalty points for customers based on previous orders by that customer. In the plugin he refers to multiple types that are found in other plugins, e.g. Order
, Customer
, LoyaltyComponent
(the latter type was created in another custom plugin in a previous tutorial).
How do I set up the dependencies to these types from my new minion plugin?
Or in general:
How do I refer to types that are declared in other commerce engine plugins (features)?
First thought was simply to refer to the other plugins directly, e.g. Sitecore.Commerce.Plugin.Orders
, Sitecore.Commerce.Plugin.Customers
, Plugin.Xxxx.Loyalty
but as the plugins are found in the feature-layer, I guess this is the wrong way to go, otherwise I would have features referencing each other.
Second thought was to refer to the Sitecore.Commerce.ServiceProxy
foundation project that is part of the commerce SDK. This proxy contains the types, deferred from the Commerce Engine API. The problem here is that the types of the ServiceProxy-project do not inherit from the base types found in Sitecore.Commerce.Core
so they are not directly usable with core functionality.
An example: In this method in my pipeline block I am trying to convert the order entities from a list to an object of type Order
, but it is not possible because Order
from the ServiceProxy project does not inherit from Sitecore.Commerce.Core.CommerceEntity
.
public override async Task<Customer> Run(Customer customer, CommercePipelineExecutionContext context)
var listName = $"Orders.ByCustomer-customer.Id";
var result = await _findEntitiesInListPipeline.Run(new FindEntitiesInListArgument(typeof(Order), listName, 0,int.MaxValue), context);
var customerOrderPoints = 0;
if (result?.List != null && result.List.Items.Any())
foreach (CommerceEntity entity in result.List.Items)
var order = (Order)entity; // <-- This is not possible because 'Order' is from ServiceProxy and inherits from another 'CommerceEntity' than the one found in Sitecore.Commerce.Core
if (order != null)
customerOrderPoints += order.HasComponent<LoyaltyComponent>()
? order.GetComponent<LoyaltyComponent>().PointsEarned
: 0;
var loyaltyComponent = customer.GetComponent<LoyaltyComponent>();
loyaltyComponent.PointsEarned = customerOrderPoints;
await _persistEntityPipeline.Run(new PersistEntityArgument(customer), context);
return customer;
So I can only make it work with the first approach but I don't want to go that way. Akshay's code is not on Github yet, so I can't see exactly how he has done.
EDIT: I noticed that the developer's guide for SXC 9 says
A plugin can also take a dependency on another plugin to extend its functionality.
This implies that it is okay to make direct references. But the Helix principles says that one feature module must never depend on another feature module, so perhaps the plugins should not be placed in the feature-layer like they are in this tutorial(?)
sitecore-commerce commerce-engine
I have been following Akshay's video tutorials about SXC, the last one about creating a minion: https://www.konabos.com/blog/creating-a-minion-for-sitecore-commerce-xc-9/. In this tutorial he creates a Plugin with a minion that calculates loyalty points for customers based on previous orders by that customer. In the plugin he refers to multiple types that are found in other plugins, e.g. Order
, Customer
, LoyaltyComponent
(the latter type was created in another custom plugin in a previous tutorial).
How do I set up the dependencies to these types from my new minion plugin?
Or in general:
How do I refer to types that are declared in other commerce engine plugins (features)?
First thought was simply to refer to the other plugins directly, e.g. Sitecore.Commerce.Plugin.Orders
, Sitecore.Commerce.Plugin.Customers
, Plugin.Xxxx.Loyalty
but as the plugins are found in the feature-layer, I guess this is the wrong way to go, otherwise I would have features referencing each other.
Second thought was to refer to the Sitecore.Commerce.ServiceProxy
foundation project that is part of the commerce SDK. This proxy contains the types, deferred from the Commerce Engine API. The problem here is that the types of the ServiceProxy-project do not inherit from the base types found in Sitecore.Commerce.Core
so they are not directly usable with core functionality.
An example: In this method in my pipeline block I am trying to convert the order entities from a list to an object of type Order
, but it is not possible because Order
from the ServiceProxy project does not inherit from Sitecore.Commerce.Core.CommerceEntity
.
public override async Task<Customer> Run(Customer customer, CommercePipelineExecutionContext context)
var listName = $"Orders.ByCustomer-customer.Id";
var result = await _findEntitiesInListPipeline.Run(new FindEntitiesInListArgument(typeof(Order), listName, 0,int.MaxValue), context);
var customerOrderPoints = 0;
if (result?.List != null && result.List.Items.Any())
foreach (CommerceEntity entity in result.List.Items)
var order = (Order)entity; // <-- This is not possible because 'Order' is from ServiceProxy and inherits from another 'CommerceEntity' than the one found in Sitecore.Commerce.Core
if (order != null)
customerOrderPoints += order.HasComponent<LoyaltyComponent>()
? order.GetComponent<LoyaltyComponent>().PointsEarned
: 0;
var loyaltyComponent = customer.GetComponent<LoyaltyComponent>();
loyaltyComponent.PointsEarned = customerOrderPoints;
await _persistEntityPipeline.Run(new PersistEntityArgument(customer), context);
return customer;
So I can only make it work with the first approach but I don't want to go that way. Akshay's code is not on Github yet, so I can't see exactly how he has done.
EDIT: I noticed that the developer's guide for SXC 9 says
A plugin can also take a dependency on another plugin to extend its functionality.
This implies that it is okay to make direct references. But the Helix principles says that one feature module must never depend on another feature module, so perhaps the plugins should not be placed in the feature-layer like they are in this tutorial(?)
sitecore-commerce commerce-engine
edited Aug 29 at 13:02
asked Aug 29 at 12:13
ebug
656
656
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
7
down vote
accepted
The minion project lives inside of your Engine solution so you would not use a proxy. The proxy is mainly for projects which live outside of the Engine environment to communicate with the engine.
You typically add the references via nuget packages for commerce plugins such as catalogs, orders, etc.
Starting in commerce I had a million questions and with the community's help, I was able to connect some of the dots. The code base will give you a good idea as they are working solutions. I have uploaded the loyalty Commerce engine and Commerce website solutions to GitHub.
Here is the link: https://github.com/konabos/Sitecore-Commerce-Loyalty
A plugin should either live in a feature project or a foundation project depending on how crucial the plugin is. For instance, a payment processing plugin central to your system should be a foundation project.
But an add on plugin such as custom fields, etc could live in a feature project in your commerce solution.
I typically have not made it a habit of modifying the Engine project.
Refer to: https://github.com/Sitecore/Sitecore.HabitatHome.Commerce and https://github.com/sitecore/sitecore.habitathome.content - they are neatly structured.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
The minion project lives inside of your Engine solution so you would not use a proxy. The proxy is mainly for projects which live outside of the Engine environment to communicate with the engine.
You typically add the references via nuget packages for commerce plugins such as catalogs, orders, etc.
Starting in commerce I had a million questions and with the community's help, I was able to connect some of the dots. The code base will give you a good idea as they are working solutions. I have uploaded the loyalty Commerce engine and Commerce website solutions to GitHub.
Here is the link: https://github.com/konabos/Sitecore-Commerce-Loyalty
A plugin should either live in a feature project or a foundation project depending on how crucial the plugin is. For instance, a payment processing plugin central to your system should be a foundation project.
But an add on plugin such as custom fields, etc could live in a feature project in your commerce solution.
I typically have not made it a habit of modifying the Engine project.
Refer to: https://github.com/Sitecore/Sitecore.HabitatHome.Commerce and https://github.com/sitecore/sitecore.habitathome.content - they are neatly structured.
add a comment |Â
up vote
7
down vote
accepted
The minion project lives inside of your Engine solution so you would not use a proxy. The proxy is mainly for projects which live outside of the Engine environment to communicate with the engine.
You typically add the references via nuget packages for commerce plugins such as catalogs, orders, etc.
Starting in commerce I had a million questions and with the community's help, I was able to connect some of the dots. The code base will give you a good idea as they are working solutions. I have uploaded the loyalty Commerce engine and Commerce website solutions to GitHub.
Here is the link: https://github.com/konabos/Sitecore-Commerce-Loyalty
A plugin should either live in a feature project or a foundation project depending on how crucial the plugin is. For instance, a payment processing plugin central to your system should be a foundation project.
But an add on plugin such as custom fields, etc could live in a feature project in your commerce solution.
I typically have not made it a habit of modifying the Engine project.
Refer to: https://github.com/Sitecore/Sitecore.HabitatHome.Commerce and https://github.com/sitecore/sitecore.habitathome.content - they are neatly structured.
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
The minion project lives inside of your Engine solution so you would not use a proxy. The proxy is mainly for projects which live outside of the Engine environment to communicate with the engine.
You typically add the references via nuget packages for commerce plugins such as catalogs, orders, etc.
Starting in commerce I had a million questions and with the community's help, I was able to connect some of the dots. The code base will give you a good idea as they are working solutions. I have uploaded the loyalty Commerce engine and Commerce website solutions to GitHub.
Here is the link: https://github.com/konabos/Sitecore-Commerce-Loyalty
A plugin should either live in a feature project or a foundation project depending on how crucial the plugin is. For instance, a payment processing plugin central to your system should be a foundation project.
But an add on plugin such as custom fields, etc could live in a feature project in your commerce solution.
I typically have not made it a habit of modifying the Engine project.
Refer to: https://github.com/Sitecore/Sitecore.HabitatHome.Commerce and https://github.com/sitecore/sitecore.habitathome.content - they are neatly structured.
The minion project lives inside of your Engine solution so you would not use a proxy. The proxy is mainly for projects which live outside of the Engine environment to communicate with the engine.
You typically add the references via nuget packages for commerce plugins such as catalogs, orders, etc.
Starting in commerce I had a million questions and with the community's help, I was able to connect some of the dots. The code base will give you a good idea as they are working solutions. I have uploaded the loyalty Commerce engine and Commerce website solutions to GitHub.
Here is the link: https://github.com/konabos/Sitecore-Commerce-Loyalty
A plugin should either live in a feature project or a foundation project depending on how crucial the plugin is. For instance, a payment processing plugin central to your system should be a foundation project.
But an add on plugin such as custom fields, etc could live in a feature project in your commerce solution.
I typically have not made it a habit of modifying the Engine project.
Refer to: https://github.com/Sitecore/Sitecore.HabitatHome.Commerce and https://github.com/sitecore/sitecore.habitathome.content - they are neatly structured.
edited Aug 29 at 13:14
answered Aug 29 at 13:08
ASura
1,683527
1,683527
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f13598%2fhow-to-refer-to-types-declared-in-other-plugins%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password