We want all products referenced on a node being deleted when the node itself is deleted.

So here is an additional setting commerce_product_reference field : "Delete referenced entities when all parents nodes has been deleted."
If enabled, when deleting the node we check if this is the last node reference on this product, and then trigger delete action.

Comments

theo_’s picture

Status: Active » Needs review
StatusFileSize
new5.22 KB

Here is the patch

theo_’s picture

Reroll it in a more generic way

joachim’s picture

I think this belongs outside of this module. IEF is a field widget, whereas this is a referential integrity rule that any widget type on a reference could feasibly use.

I'm planning on working on a general referential integrity module, BTW -- but as far as this patch goes I would suggest this should be a wontfix.

dave reid’s picture

Yeah this is more in the area of http://drupal.org/sandbox/drothstein/1775816, which joachim you may want to look at since it works for any field type that defines its foreign keys correctly.

bojanz’s picture

Title: Delete referenced commerce_product entities when all parents node has been deleted. » Add optional functionality for deleting referenced entities when the parent entity has been deleted
Assigned: theo_ » Unassigned
Status: Needs review » Fixed

Committed this:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/db4d479?...

It's a stop-gap measure. Without this, line items don't get removed when an order gets deleted, because Commerce only targets its own widget.
And there's the same problem for product variations in Kickstart, which was a critical bug there.

I can't pull a sandbox into the distro, so as soon as there's a good replacement, I can revert this patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.