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

Vote:
 

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!

#279396
Edited, Apr 28, 2022 9:07
Vote:
 

versions:

CMS 11.2

Commerce 13.26

#279397
Apr 28, 2022 9:09
Vote:
 

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

   [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
    public class PromotionVehicleExclusions : IConfigurableModule
    {
        public void Initialize(InitializationEngine context)
        {
            SetupExcludedPromotionEntries(context);
        }
        public void ConfigureContainer(ServiceConfigurationContext context)
        {
        }
        public void Uninitialize(InitializationEngine context)
        {
        }
        private void SetupExcludedPromotionEntries(InitializationEngine context)
        {
            var filterSettings = context.Locate.Advanced.GetInstance<EntryFilterSettings>();
            filterSettings.ClearFilters();
            //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.

#279398
Apr 28, 2022 10:19
Vote:
 

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?

#280053
May 09, 2022 20:25
Vote:
 

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 

#280163
May 11, 2022 8:16
Vote:
 

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. 

#284041
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.