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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

OnkelTem’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, rules-condition-entity-exists-upgraded_7.x-1.0.patch, failed testing.

pcambra’s picture

I wonder why are we implementing this in first place, shouldn't be in entity api module itself?

rszrama’s picture

Cool, 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.

rszrama’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs work » Needs review

Trying to retest on 7.x-1.x-dev.

pcambra’s picture

We could try to push it into entity.rules.inc and mark this as "to be removed" if it gets committed.

OnkelTem’s picture

Maybe its better to have "Entity count by property" instead of "Exists" which becomes degenerate case for count >= 1?

mrfelton’s picture

Cool, thats much better. Although, I realy need to be able to see it an entity exists by checking multiple properties.

rszrama’s picture

Yeah, 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.

mrfelton’s picture

@rszrama - exactly what we ended up doing!

er_gaurav_sharma’s picture

rszrama’s picture

Issue tags: +1.3 review

Tagging.

helior’s picture

FileSize
7.67 KB

The 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?

rszrama’s picture

Status: Needs review » Fixed

Great, 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nedjo’s picture

I 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.