Created
December 20, 2012 15:06
-
-
Save emjayess/4345798 to your computer and use it in GitHub Desktop.
A drupal 7 workflow rule for drupal commerce that auto-generates 1 new "product display" node (of type "my_product_display") for each newly created product entity; the 'data_set' action establishes a reference from the auto-generated display to the created product.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "rules_auto_create_product_display" : { | |
"LABEL" : "Auto-create product display", | |
"PLUGIN" : "reaction rule", | |
"REQUIRES" : [ "rules", "entity" ], | |
"ON" : [ "commerce_product_insert" ], | |
"IF" : [ | |
{ "entity_has_field" : { "entity" : [ "commerce-product" ], "field" : "field_sku" } } | |
], | |
"DO" : [ | |
{ "entity_create" : { | |
"USING" : { | |
"type" : "node", | |
"param_type" : "my_product_display", | |
"param_title" : "[commerce-product:title]", | |
"param_author" : [ "commerce-product:creator" ] | |
}, | |
"PROVIDE" : { "entity_created" : { "my_new_product_display" : "My New Auto-Created Product Display" } } | |
} | |
}, | |
{ "data_set" : { | |
"data" : [ "my-new-product-display:field-products:0" ], | |
"value" : [ "commerce-product" ] | |
} | |
}, | |
{ "entity_save" : { "data" : [ "my-new-product-display" ] } } | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment