How do I Fetch Product Author from Commerce Order With Rules
I am trying to fetch the author of products found in an order to alert them they have a new order to confirm. I am trying to use rules to create new content or send them an email. I have my current attached rules export here to view. Right now i am just trying to create a new basic node to test the concept of grabbing the product's author.
{ "rules_notify_tour_operator" : {
"LABEL" : "Notify Author",
"PLUGIN" : "reaction rule",
"TAGS" : [ "Orders" ],
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_order_insert" ],
"IF" : [
{ "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_product" } }
],
"DO" : [
{ "entity_fetch" : {
"USING" : { "type" : "commerce_product", "id" : [ "commerce-order:order-id" ] },
"PROVIDE" : { "entity_fetched" : { "fetched_product" : "Fetched Product" } }
}
},
{ "entity_fetch" : {
"USING" : { "type" : "user", "id" : [ "fetched-product:creator:uid" ] },
"PROVIDE" : { "entity_fetched" : { "fetched_author" : "Fetched Author" } }
}
},
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "page",
"param_title" : "Test Message",
"param_author" : [ "fetched-author" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "entity_save" : { "data" : [ "entity-created" ] } }
]
}
}
So far no luck any help would be greatly appreciated.
Originally found here https://drupal.org/node/2050565
Comments
It took a little bit of trial and error with the correct data selectors, but I managed to get it working thanks to your guidance. Thanks!