Concrete5 Bulk Deleting Products from Ecommmerce

The following is a handy little script to use if you need to delete a bunch of Concrete5 product pages and products from your ecommerce website.  It is particularly handy if you had a bad data import or need to redo your ecommerce products.

The first thing that you need to do is create a tools page:

with this content:

defined('C5_EXECUTE') or die(_("Access Denied.")); Loader::model('product/model', 'core_commerce'); $product_ids = array(5); foreach($product_ids as $pID) { $pr = CoreCommerceProduct::getByID($pID); if(!($pr instanceof CoreCommerceProduct)) { throw new Exception(t('Invalid product ID.')); } $pr->deleteProductCollection(); // delete the page $res = $pr->delete(); // delete the actual product echo $pID . " deleted
; } echo "done"; exit;

The populate the $product_ids = array() with ids or an id range from the CoreCommerceProducts table for the products you'd like to delete and then this will remove all the products and their pages.  Please be careful with this script because once you delete everything you can't get it back.  After completing the buld delete your should remove or comment out the file from your server.

Please add a comment

Leave a Reply

(Your email will not be publicly displayed.)

For more information about this blog or Concrete5 please contact Jamie Johnson.