1

After a Commerce product is created I need to create a new product display node and reference the product in a field.

This is my first time using Rules. I can create a new product display node but I cant figure out how to populate the 'referenced product' field.

4
  • I would steer clear of this. There are likely to be situations where you're going to be creating a product that you don't want a display for (i.e. small t-shirt, med t-shirt = 2 products/1 display). I'd be more inclined to do it the other way round using Inline Entity Form and create products and displays at the same time.
    – Chapabu
    Commented Oct 9, 2012 at 11:16
  • No, my product and product displays will always have a 1 to 1 relationship. I want it to work the way around that ive described so you can administer products from the normal product admin views.
    – Evanss
    Commented Oct 9, 2012 at 11:30
  • If you use the IEF then you can still administer products from the normal product admin screen. Visually you're only creating one piece of content. It'll be more robust than Rules and allow for future-proofing.
    – Chapabu
    Commented Oct 9, 2012 at 11:32
  • However i would still like to know the answer to my question even if its just to improve my knowledge.
    – Evanss
    Commented Oct 9, 2012 at 11:42

1 Answer 1

0

Despite the limited information in your question, you should be able to create such rule (using the Rules module) like so:

  • Use a Rules Event that is related to "When Commerce product is created" (something similar to "After saving content"?).

  • Add a Rules Condition to make your referenced product field become available to use in a Rules Action. This condition can be either of those alternatives:

    • "Entity has field".
    • "Content is of type".
  • Add Rules Action "Set a data value" for your referenced product field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.