2

I am trying to follow the Commerce Product model of Node Display that references each product.

When I create a product, Rules automatically creates a Node with the same title, and references the product in the node.

However also using Rules, I would like to perform the following:

  • When product is updated, update the referencing Nodes Title / Published attribute
  • When product is deleted, delete the referencing Node

I can't figure out the way to fetch the Node Entity in Rules at all.

Thanks!

EDIT:

As per @rfay's comment below, I've attempted to go down the Bi-directional reference route, which means installing the References module and create a node_reference field in the product that points back to the node.

Unfortunately however it seems Rules is not providing the means to fetch the node entity, as it is not recognizing the existence of the node_reference field on the product by which to fetch the node from.

  • 2
    Unfortunately, you don't have a bidirectional reference, so I doubt there's a way to access the node from the product currently. The CNR module (for node references) does this successfully. – rfay Aug 2 '11 at 19:53
  • Yes I was thinking of making a 2 way reference. It feels a little bit dirty, but I suppose this is what I need to do. CNR module looks great thanks :) – DanH Aug 3 '11 at 2:25
1

If you want to delete the product display node, you need to hook the entity update (e.g. on node update). If the product reference field is empty, you can delete the node. But the product reference field must be a required field.

When the Drupal commerce module deletes a product, it needs also to delete all the references from the product display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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