I'm looking to load a list of Users by an Entity Reference Property within Rules. There may be times when I need to load hundreds or thousands of Users that have a matching Property to update a secondary Property. I'm having a difficult time determining the best performance option.
Here's my use case:
Users within our website may be linked to a Company (stored as a Node with Content-Type: company
). When any user of this Company purchases membership, the company
Node is updated with a Taxonomy Term Reference "Member." Then, every employee (read: User with entity reference to the same company
node) of that organization needs to have a Taxonomy Reference field within their account updated to reflect they are a "Member (Corp)."
My Rules Based Solutions (that is executed when the order is first Paid In Full that sets the Data Value for that Property of the Company node, then...):
Solution A (Rules without VBO View):
- Fetch all User Entities By Property:
company
, wherecompany
= Company node. - Loop through User list.
- Check that Entity has Field: "Membership Status."
- Set Data Value: "Membership Status" = "Member (Corp)."
Solution B (Rules with: Load a List of Entities from a VBO View):
- Pass
nid
as parameter to view. - Loop through returned List.
- Check that Entity has Field: "Membership Status."
- Set Data Value: "Membership Status" = "Member (Corp)."
Solution C (Rules with: Load a List of Entity IDs from a VBO View):
- Pass
nid
as parameter to view. - Loop through returned List.
- Fetch User Entity by ID.
- Check that Entity has Field: "Membership Status."
- Set Data Value: "Membership Status" = "Member (Corp)."
I'm hesitant to load up every Entity that matches due to Performance implications; however, being fairly new to Drupal, I'm not sure the most efficient method to bulk update all of the affected Users.
Can you help me better understand the performance implications of these solutions? Perhaps, I'm missing a better option that I haven't considered? Thanks in advance for your help!
*This question is in reference to Drupal 7.