public function DoDeleteProducts($ids)
 {
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     foreach ($ids as $key => $id) {
         if (!is_numeric($id) || $id <= 0) {
             unset($ids[$key]);
         }
     }
     // Start a transaction
     $GLOBALS["ISC_CLASS_DB"]->Query("start transaction");
     // The products and related data will be removed from the following tables:
     //
     //     - Products
     //     - CategoryAssociations
     //     - Product_CustomFields
     //     - Product_Images
     //     - Product_Variation_Combinations
     //     - Product_Downloads
     //		- product_configurable_fields
     // added by blessen
     // -isc_qalifiers
     // - isc_import_variations
     // What we do here is feed the list of product IDs in to a query with the vendor applied so that way
     // we're sure we're only deleting products this user has permission to delete.
     $prodids = implode("','", array_map('intval', $ids));
     $vendorId = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId();
     if ($vendorId > 0) {
         $query = "\n\t\t\t\t\tSELECT productid\n\t\t\t\t\tFROM [|PREFIX|]products\n\t\t\t\t\tWHERE productid IN ('" . $prodids . "') AND prodvendorid='" . (int) $vendorId . "'\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $prodids = array(0);
         while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $prodids[] = $product['productid'];
         }
         $prodids = implode("','", array_map('intval', $prodids));
     }
     //echo "productid = ".implode(' OR productid=',$ids);exit;
     // Build a list of queries to execute
     $queries[] = sprintf("delete from [|PREFIX|]categoryassociations where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_customfields where fieldprodid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]reviews where revproductid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_search where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_words where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_images where imageprodid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_downloads where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]wishlist_items where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_configurable_fields where fieldprodid in ('%s')", $prodids);
     //added by blessen
     $queries[] = sprintf("delete from [|PREFIX|]qualifier_value where pid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]import_variations where productid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]install_images where imageprodid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]install_videos where videoprodid  in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]product_videos where videoprodid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]audio_clips where audioprodid in ('%s')", $prodids);
     //Added by Blessen
     $queries[] = sprintf("delete from [|PREFIX|]instruction_files where instructionprodid in ('%s')", $prodids);
     $queries[] = sprintf("delete from [|PREFIX|]article_files where articleprodid in ('%s')", $prodids);
     // Delete the product images from the file system
     $query = sprintf("select imagefile from [|PREFIX|]product_images where imageprodid in ('%s')", $prodids);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         @unlink(APP_ROOT . "/../" . GetConfig('ImageDirectory') . "/" . $row['imagefile']);
     }
     // Delete the install images from the file system
     $query = sprintf("select imagefile from [|PREFIX|]install_images where imageprodid in ('%s')", $prodids);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         @unlink(APP_ROOT . "/../install_images/" . $row['imagefile']);
     }
     /*
     // Delete the product videos from the file system
     $query = sprintf("select videofile, videotype, systemvideofile from [|PREFIX|]product_videos where videoprodid in ('%s') AND ((videotype != 1) || (videotype = 1 AND isdownloaded=2))", $prodids);
     
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if($row['videotype'] == 1)    {
             $filename = $row['systemvideofile'];
         }
         else    {
             $filename = $row['videofile']; 
         }
         @unlink(APP_ROOT."/../".GetConfig('VideoDirectory')."/".$filename);
     }    
     
     // Delete the install videos from the file system
     $query = sprintf("select videofile, videotype, systemvideofile from [|PREFIX|]install_videos where videoprodid in ('%s') AND ((videotype != 1) || (videotype = 1 AND isdownloaded=2))", $prodids);
     
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if($row['videotype'] == 1)    {
             $filename = $row['systemvideofile'];
         }
         else    {
             $filename = $row['videofile']; 
         }
         @unlink(APP_ROOT."/../".GetConfig('InstallVideoDirectory')."/".$filename);
     }    
     */
     $query = sprintf("select instructionfile, instructiontype, systeminstructionfile from [|PREFIX|]instruction_files where instructionprodid in ('%s') AND ((instructiontype != 1) || (instructiontype = 1 AND isdownloaded=2))", $prodids);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($row['instructiontype'] == 1) {
             $filename = $row['systeminstructionfile'];
         } else {
             $filename = $row['instructionfile'];
         }
         @unlink(APP_ROOT . "/../instruction_file/" . $filename);
     }
     // Delete the install videos from the file system
     $query = sprintf("select articlefile, articletype, systemarticlefile from [|PREFIX|]article_files where articleprodid in ('%s') AND ((articletype != 1) || (articletype = 1 AND isdownloaded=2))", $prodids);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($row['articletype'] == 1) {
             $filename = $row['systemarticlefile'];
         } else {
             $filename = $row['articlefile'];
         }
         @unlink(APP_ROOT . "/../article_file/" . $filename);
     }
     // Delete the product downloads from the file system
     $query = sprintf("select downfile from [|PREFIX|]product_downloads where productid in ('%s')", $prodids);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         @unlink(APP_ROOT . "/../" . GetConfig('DownloadDirectory') . "/" . $row['downfile']);
     }
     $vc_queries = $this->_DeleteVariationCombinationsForProduct($prodids, true);
     $queries = array_merge($vc_queries, $queries);
     // Delete the product record here so we can keep a record of what was deleted for the accounting modules
     $entity = new ISC_ENTITY_PRODUCT();
     $entity->multiDelete($ids);
     foreach ($queries as $query) {
         $GLOBALS["ISC_CLASS_DB"]->Query($query);
     }
     $err = $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg();
     if ($err != "") {
         // Queries failed, rollback
         $GLOBALS["ISC_CLASS_DB"]->Query("rollback");
         return false;
     } else {
         // Query was a success
         $GLOBALS["ISC_CLASS_DB"]->Query("commit");
         return true;
     }
 }