Tags/topics: 
1
Answers
Vote up!
0
Vote down!

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

Asked by: woprrr
on June 11, 2012

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.

- woprrr on June 11, 2012

1 Answer

Vote up!
2
Vote down!

So I modified my rule and this gives for the "CREATION" display "node" has the submission of a product.

{ "rules_creation_node_mangas" : {
"LABEL" : "Cr\u00e9ation de node Mangas",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_product_insert" ],
"IF" : [
{ "data_is" : { "data" : [ "commerce-product:type" ], "value" : "YOUR_NODE_NAME_MACHINE" } }
],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "YOUR_PRODUCT_TYPE",
"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" ]
}
}
]
}
}

Answer by: woprrr
Posted: Jun 11, 2012