Try our conversational search powered by Generative AI!

Custom OrderPromotionProcessorBase not always used

Vote:
 

Hi!

I have built my own OrderPromotionProcessorBase to handle order discounts.

[ServiceConfiguration(Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomSpendAmountGetOrderDiscountProcessor : OrderPromotionProcessorBase

It works every now and then. It works just fine for a while and suddenly it stops working and the default behavior is back.

Is there some way to configure so that Commerce always uses my custom processor and not the default one?

Thanks!

/Kristoffer

#181827
Edited, Aug 31, 2017 10:45
Vote:
 

Sounds like a bug to me. Check the places where it's not used and reflect the code to see if somewhere the code is not using it injected, but instancing it instead.

#181828
Aug 31, 2017 11:00
Vote:
 

Adding the ServiceConfiguration attribute will add your type to the container, but it will not remove the existing ones. What if you evict the existing one, the one you want to replace, from the container (usually done in an initialization module)?

I also wonder if you might need to set ServiceType="typeof(OrderPromotionProcessorBase<SpendAmountGetOrderDiscount>)" on the ServiceConfiguration. If no ServiceType is set that means that it will be registered for the current type, in this case CustomSpendAmountGetOrderDiscountProcessor.

If you want to look into how the processor resolving is done, it is handled by the class EPiServer.Commerce.Marketing.PromotionProcessorResolver. It is also possible to replace that resolver, if you want to modify the logic.

Regards

Per Gunsarfs 

#181831
Aug 31, 2017 11:29
Vote:
 

One easier approach is to set your processor Priority to higher value, for example, 100. This will make sure it is chosen everytime.

I'll log a bug for it. - Or maybe not. The Priority property is what needs to be overriden...

#181836
Edited, Aug 31, 2017 11:55
Vote:
 

One easier approach is to set your processor Priority to higher value, for example, 100. This will make sure it is chosen everytime.

I'll log a bug for it. 

#181837
Aug 31, 2017 11:56
Vote:
 

Thanks Per and Quan!

Actually both ways works. Either setting the ServiceType or override the Priority.

/Kristoffer

#181840
Aug 31, 2017 13:16
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.