The hook_commerce_product_can_delete() is called to block any products from being deleted, ie if they are referenced in line items. However, the product_ids array is never updated, so the controller still deletes all of them.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | fix-product-can-delete-1293754-1.patch | 568 bytes | recrit |
Comments
Comment #1
recrit commentedpatch to address this issue
Comment #2
rszrama commentedYou da man. Nice catch and sweet patch.
Comment #4
jbeall1369 commentedI'm new, and I cannot delete products. I get this error: "This product is referenced by a line item and therefore cannot be deleted. Disable it instead." How do I use a patch?
Comment #5
rszrama commentedYou don't need a patch - that's the intended behavior of Drupal Commerce. What you need instead is to just delete the order that contains the line item. Look under your Shopping Carts tab, as it might be on an uncompleted order.
Comment #6
jbeall1369 commentedThere are no orders or shopping carts...
Comment #7
rszrama commentedThen you must have an orphaned line item somewhere, one that was created manually on an order add form but the order itself was never saved. It's unfortunate, but there is no way to delete these directly through the default UI. One thing you can do is simply create a View of line items and list them all out as an admin to see and possibly delete; I'm not sure how deletion would work through there without Rules + VBO... and that's getting overly complicated. Many people have just deleted the line items from the commerce_line_item table and product references from the field_commerce_product_data table (or whatever the name of it is). Make sure you clear the cache after doing that, too, and don't forget the related revision table for the field data.