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.
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?
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
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.
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:
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:
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!