Delete multiple products in Magento

The fastest way to do it is to run this query directly.

DELETE FROM `catalog_product_entity` WHERE `sku` IN ('SKU1', 'SKU2', ...., 'SKU1000');

Everything should cascade nicely. attribute values will be deleted, category relations will be deleted, upsells, crosssells and related and so on.

[EDIT]
There is a catch to this. Thanks to STW for spotting this. The reviews and ratings will remain orphans because there is no foreign key to the products table for them.


All due respect to Marius, but please don't interact with the database directly if it's at all avoidable. Maybe the related tables will be updated automatically, if your release of Magento and all your extensions are bug-free in all the right places. But if they're not, that sort of thing can destroy your site.

Instead, you can use Magento's own CSV import feature.

Just list your SKUs in a file, simple as:

sku
ABC1
ABC2
ABC3

...etc. Then save as a CSV file.

Then, in System > Import/Export > Import, select Entity Type: Products and Import Behaviour: Delete Entities, and import this file. And that's it!


You can do it programmatically. Create a skustodelete.csv listing all skus to be deleted and after that here is the code to proceed further

    require_once 'app/Mage.php';
    Mage :: app("default")->setCurrentStore(Mage_Core_Model_App :: ADMIN_STORE_ID);
    $skuAll = array();
    $file_handle = fopen("skustodelete.csv", "r");
    $catalog = Mage::getModel('catalog/product');
   while (!feof($file_handle)) {
     $line_of_text = fgetcsv($file_handle, 1024);
     $allSku = $line_of_text[0];
     $product = $catalog->loadByAttribute('sku', $allSku);
     try {
          $product->delete();
          echo "Product with ID: " . $product->getId() . " Deleted Successfully". PHP_EOL;
     } catch (Exception $e) {
          echo "Product with ID: " . $product->getId() . "cannot be deleted" . PHP_EOL;
     }
}
echo "Finish Delete";