While synchronizing Products and Nodes via Rules, I got strange form of "Entity exists by property" condition - it knew nothing about the fetching entity's properties. At that on the similar form of Action "Fetch entity by property" entity properties are displayed.
After hours of debugging it was surprising to know that respective code for some odd reason lives in commerce_checkout module - being so useful outside the module.
I patched it mostly by copy-pasting code from Action 'Fetch entity by property'. It is a quick patch, I didn't consider much possible consequences, but it works for me, please review it and try.
Comment | File | Size | Author |
---|---|---|---|
#13 | entity-exists.patch | 7.67 KB | helior |
rules-condition-entity-exists-upgraded_7.x-1.0.patch | 3.05 KB | OnkelTem | |
Comments
Comment #1
OnkelTem CreditAttribution: OnkelTem commentedComment #3
pcambraI wonder why are we implementing this in first place, shouldn't be in entity api module itself?
Comment #4
rszrama CreditAttribution: rszrama commentedCool, will review the patch. Just wanted to say this code is in Checkout b/c we couldn't get it into Rules at the time.
Comment #5
rszrama CreditAttribution: rszrama commentedTrying to retest on 7.x-1.x-dev.
Comment #6
pcambraWe could try to push it into entity.rules.inc and mark this as "to be removed" if it gets committed.
Comment #7
OnkelTem CreditAttribution: OnkelTem commentedMaybe its better to have "Entity count by property" instead of "Exists" which becomes degenerate case for count >= 1?
Comment #8
mrfelton CreditAttribution: mrfelton commentedCool, thats much better. Although, I realy need to be able to see it an entity exists by checking multiple properties.
Comment #9
rszrama CreditAttribution: rszrama commentedYeah, we ran into that same issue in training yesterday - the only viable solution without reproducing EntityFieldQuery in a condition and an action is to just write a custom condition or action for your scenario. That's what I would recommend.
Comment #10
mrfelton CreditAttribution: mrfelton commented@rszrama - exactly what we ended up doing!
Comment #11
er_gaurav_sharma CreditAttribution: er_gaurav_sharma commentedrules-condition-entity-exists-upgraded_7.x-1.0.patch queued for re-testing.
Comment #12
rszrama CreditAttribution: rszrama commentedTagging.
Comment #13
helior CreditAttribution: helior commentedThe patch worked very well, actually :)
I'm moving this out to the main Commerce module since it's abstracted well enough to not be trapped in the checkout module.
Btw, I believe this was the issue that Ryan was alluding to #1031530: Add a User action "Send account e-mail" that didn't make it to Rules. I agree with Pedro that we should probably mark our implementation with some "to be removed" when this issue is fixed.
@mrfelton Maybe I'm not understanding, but couldn't you still achieve checking multiple properties by using a condition set containing multiple "entity exists by property" conditions?
Comment #14
rszrama CreditAttribution: rszrama commentedGreat, I've committed the patch - works awesome. Welcome to the committers log, OnkelTem! If you want, I think a great follow-up feature request would be to add the entity count to this condition as a 'provides' variable from the condition.
Comment #16
nedjoI updated the Rules patch that came out of this and pulled it into a new issue: #1777204: Add condition "Entity exists by property". Reviews appreciated.