public function CommerceProductEntityController::delete in Commerce Core 7
Deletes multiple products by ID.
Parameters
$product_ids: An array of product IDs to delete.
$transaction: An optional transaction object.
Return value
TRUE on success, FALSE otherwise.
Overrides DrupalCommerceEntityController::delete
File
- modules/
product/ includes/ commerce_product.controller.inc, line 149 - The controller for the product entity containing the CRUD operations.
Class
- CommerceProductEntityController
- The controller class for products contains methods for the product CRUD operations.
Code
public function delete($product_ids, DatabaseTransaction $transaction = NULL) {
if (!empty($product_ids)) {
$products = $this
->load($product_ids, array());
// Ensure the products can actually be deleted.
foreach ((array) $products as $product_id => $product) {
if (!commerce_product_can_delete($product)) {
unset($products[$product_id]);
}
}
// If none of the specified products can be deleted, return FALSE.
if (empty($products)) {
return FALSE;
}
parent::delete(array_keys($products), $transaction);
return TRUE;
}
else {
return FALSE;
}
}