What are you doing in a nice Saturday morning, Joel? :)
There is no easy way to do that - I just went and check the source code (what am I doing as well?) - and there is no "framework" way for doing that. But the point of the promotion engine is to be extensible. You can extend your PromotionData to add some "ExcludedEntries" property, and handle that in your processor.
Yeah exactly, that'd be the "Way 1" of doing it, but applying that to all built in promotions would mean create one custom promotion for each built in one..
I'm currently working from Avensias office in Philippines. A combination of being quite alone at "home" and being sick leads me to my computer! :P
I think the entry filter-thingy was actually made to fulfill a request from you ;) - if the requirement was more clear at the beginning, we would have something by now :)
However that does not mean we won't do anything about that - I'll create a story so we can look into it. However it will have to compete with other (high priority) stories in our backlog. But you already know how to boost its priority.
Yeah I know about the entry filter, it was so we could find a framework way to exclude giftcards from promotions. I don't think we've officially asked for this specific feature before however, as they differ a bit. I wouldn't want to have this feature instead of entry filter when it comes to not running promotions on gift cards for example :)
Thanks for answering, anyways. I'll probably build a custom representation of all built in promotions for now, using as much epi code as I can. I have a faint memory that someone said that it should be done and in production before black friday, but I hope I heard wrong!
Joel, Quan, did you ever come up with a better solution to this problem than having to build custom representations of all built in promotions? In my case I'd like to exclude certain articles from Entry- and OrderPromotions but not from ShippingPromotions.
I'll look into this, the technical part would be fairly easy, the non technical part (how to convince my colleagues to accept the changes) is much more challenging. But, let's see
An update - because I know you like updates - I was able to make it works, both at UI and API level. The product manager is happy with it so it's probably happening. It still needs polishing, but there is a chance that we are going to make it in Commerce 13
A customer I'm working on has for a while asked us to implement a feature where they can create a promotion, select which content they want to be the condition and then select some content that should not be a part of the promotion. I've not really theorized a solution for this, so we've done some workarounds that worked well enough to fulfill the use case they had. However, I want to reach out and see if someone can help me suggest a way of implementing this nicely.
Before anyone asks "Why not just include what should be included in the promotion?", I think I'm safe to say a very common usage of promotions is have one that affects the entire assortment or large portions of it, but that a few products are too "premium" to be affected by a discount.
Way 1: The obvious way
Create a custom promotion processor for the promotion. You can do whatever logic you want from in there, right? Well, this feature should be for all promotions, so that'd mean we'd have to create a custom promotion for every existing built in promotion. A class that inherits the data class for that specific promotion adding the list of exluded content and a processor that overrides the old promotion processor and somewhere injects the logic to exclude the products selected in the list of excluded content.
So in the end the solution is quite ugly, will have to mean creating tons of code that "already existed" and if Epi releases a new promotion implementation, we will have to manually build that one as well.
Way 2: EntryFilterSettings to our rescue?
The fairly new way of excluding products from promotions, does look very promising, just by looking at the description. However it doesn't fit this use case, as this should be promotion specific. Maybe promotion A should exclude product P1 and promotion B should exclude P2. We can't solve that by the EntryFilterSettings, since that one is used in the promotion engine, removing the items before the engine starts running the specific promotion processors.
So this method is unfortunately a no-go. Even though we do use EntryFilterSettings for a lot of other purposes, such as always excluding gift cards from promotions!
Way 3: Make Epi implement a way!
In all seriousness I'm looking for a way of implementing this. Am I missing something, am I tunneled visioned and there is an super easy way of achieving this? Currently I'm leaning to implementing it as Way 1, but not super excited about it.