Try our conversational search powered by Generative AI!

ICart.ApplyDiscounts follows secondary relationships of the products & times out


We sell products (services) for vehicles, and created vehicle structure in our catalog.

After that we linked all our products with the vehicles.

What is happening next, when a product is in the cart, EPI reads all vehicles linked to that cart.

This is how we link the service product variants with the vehicles: 

           IRelationRepository.UpdateRelation(new NodeEntryRelation()
                IsPrimary = false,
                Parent = vehicle,
                Child = service

The problem that the cart calculation stopped working completely - a service (say wheel alignment) can be linked to 10,000 vehicles.

when this code executes: 

ICart.ApplyDiscounts(IPromotionEngine, new PromotionEngineSettings())

It never exists the line. If I try to step into the line, I'm hitting setters on vehicle node which suggests it is reading the nodes from the catalog, and the only reason it can read them from this line of code is because they are linked.

The issue is happening when there is an active (any) promotion in the system.

I'm now wandering how I can stop cart / promotion engine to traverse the linked entities, as it completely throws the release off track and putting me on fire.

Please help!

Edited, Apr 28, 2022 9:07


CMS 11.2

Commerce 13.26

Apr 28, 2022 9:09

Adding more information to the topic, I tried to filter promotion engine using module as below

    public class PromotionVehicleExclusions : IConfigurableModule
        public void Initialize(InitializationEngine context)
        public void ConfigureContainer(ServiceConfigurationContext context)
        public void Uninitialize(InitializationEngine context)
        private void SetupExcludedPromotionEntries(InitializationEngine context)
            var filterSettings = context.Locate.Advanced.GetInstance<EntryFilterSettings>();
            //Add filter predicates for a whole content type.
            filterSettings.AddFilter<VehicleModelVersionNode>(x => false);
            filterSettings.AddFilter<VehicleManufacturerModelNode>(x => false);
            filterSettings.AddFilter<VehicleManufacturerNode>(x => false);
            filterSettings.AddFilter<NodeEntryRelation>(x => false);

In the exclusion the 3 nodes are vehicle hierarchy in the catalog (manufacturer, model, vehicle) and also relationship entity

That didn't change anything, even though the initialisation is executed. The internal function (x => false) is never executed.

Apr 28, 2022 10:19

AddFilter method takes I believe inherits anything from EntryContentBase, so products, variants, bundles and packages.

In your example, you've put a node and also a relation object in there. I don't think that will work.

You'll have to find another way to stop the PromotionsEngine traversing your 10k relations.

Could you give more context around what the catalog structure looks like?

May 09, 2022 20:25

Does it have to be a child of categories (in a node-entry relation)? Alternative is that you add a property to your product (tires) as a flag (Serviceable = true/false) for example 

May 11, 2022 8:16

this had been resolved by EPI support by providing a custom CollectionTargetEvaluator

It has one function override:

        private IEnumerable<NodeRelation> GetParentNode(ContentReference itemLink)
            // original code >> return _relationRepository.GetParents<NodeRelation>(itemLink);
            var firstNode = _relationRepository.GetParents<NodeRelation>(itemLink).FirstOrDefault();
            return (firstNode != null)
                ? new List<NodeRelation> { firstNode }
                : new List<NodeRelation> { };

There is no other solution as EPI would traverse all relations of a product, including secondary, and there is no configuration to change that. 

Jul 21, 2022 2:27
* 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.