Delete all commerce products
The commerce_product_delete_multiple function can be used to bulk delete products. Similar to other ENTITY_delete_multiple functions, an array of entity ids is passed as an argument.
Drupal_set_time_limit is used to override the default 30 seconds that a script is allowed to run.
drupal_set_time_limit(0); $product_ids = db_select('commerce_product', 'p') ->fields('p', array('product_id')) ->execute()->fetchCol(); // $products = commerce_product_load_multiple($product_ids); commerce_product_delete_multiple($product_ids);
Products can't be deleted when there are references in orders. First of all, delete all orders.