public function CommerceProductInlineEntityFormController::delete in Inline Entity Form 7
Overrides EntityInlineEntityFormController::delete().
Disables products that can't be deleted (because they are already referenced from a line item, or for some other reason), deletes the rest.
Overrides EntityInlineEntityFormController::delete
File
- includes/
commerce_product.inline_entity_form.inc, line 392 - Defines the inline entity form controller for Commerce Products.
Class
- CommerceProductInlineEntityFormController
- @file Defines the inline entity form controller for Commerce Products.
Code
public function delete($ids, $context) {
$products = entity_load('commerce_product', $ids);
foreach ((array) $products as $product_id => $product) {
if (!commerce_product_can_delete($product)) {
$product->status = FALSE;
entity_save('commerce_product', $product);
unset($products[$product_id]);
}
}
// When the parent entity is being removed, we don't want to trigger the
// products deletion right away, otherwise the magic that happens in
// commerce_product_reference_commerce_product_delete() will ultimately
// trigger an entity_save() on the parent entity that is about to be
// deleted from the database.
drupal_register_shutdown_function('commerce_product_delete_multiple', array_keys($products));
}