Creates a rule that creates content when submitting a product
The title is pretty self-explanatory so I created a rule that allows me to create content with the submision of a product, but with several types of products, each corresponding with a content type example: Product manga -> content manga.
Now here is my rule.
{ "Cr\u00e9ation automatique des affichages front" : {
"LABEL" : "Cr\u00e9ation automatique des affichages front",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_product_insert" ],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "produits_mangas",
"param_title" : [ "commerce-product:title" ],
"param_author" : [ "commerce-product:creator" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "list_add" : {
"list" : [ "entity-created:field-product" ],
"item" : [ "commerce-product" ]
}
}
]
}
}
What I would do is create the conditions so that I can check on what product type I create the entity and therefore it creates the right kind of content.
So, in my case I want to create:
Product type: Manga sends Content type: Manga
Product type: Content type sends Comics: Comics
Comments
Posted by rszrama on June 7, 2012 at 4:14pm
Status: active » fixed
Welcome to the issue queue! : )
For future support requests, please take advantage of the new Q&A system at http://www.drupalcommerce.org/questions. (Feel free to post bug reports or feature requests in here, though.)
In your case, all you really need to do is either 1) add a "Data comparison" condition that checks the product type and create a separate rule for each product type to map it to the proper node type or 2) use the same string for the product type and node type so that you don't even need the condition.
There are other issues about doing this sort of synchronization through Rules, too, so you might see if they have any conditional logic to offer.