Sign up ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Is there any way to delete multiple products by filtering with SKU? I have around 1000 products that I want to delete.

share|improve this question

5 Answers 5

up vote 8 down vote accepted

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.

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.

share|improve this answer
dont forget to reindex after this (if you use flat product catalog) – Vladimir Kerkhoff Jun 29 '14 at 6:43
This is basically what the Admin Import/Export tool does when using it to perform mass deletions. It is extremely fast compared to calling ->delete() but will dodge any code listening for events. In stock Magento it appears that reviews and ratings will be orphaned (they won't be deleted when their associated product is). – STW Oct 1 at 13:22
@STW. Nice catch. I completely forgot about the reviews and ratings. – Marius Oct 1 at 13:24

Kevin S, you can delete product by csv file. Just follow the billow step

Step 1 :

Create a csv file and past the skus which you want to delete from system. Give the file name as skus.csv

Step 2 :

Create & replace a php file in your root directory. Then past the following code

require_once '../app/Mage.php';
Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
$skuAll =array();
$file_handle = fopen("skus.csv", "r");
 while (!feof($file_handle) ) {
    $line_of_text = fgetcsv($file_handle, 1024);
$allSku = $line_of_text[0];

$products = Mage::getResourceModel('catalog/product_collection')
        'sku', array('in' => $allSku)

        foreach ($products as $key => $pId)
                $product = Mage::getModel('catalog/product')->load($pId)->delete();
                echo "successfully deleted product with ID: ". $pId ."<br />";
            catch (Exception $e) 
                echo "Could not delete product with ID: ". $pId ."<br />";

Note : I recommended to you before run this code you must get the backup. I hope its will be help you.

share|improve this answer

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:


...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!

share|improve this answer
fyi - generally I agree that avoiding direct DB interaction is best; however this is actually how Magento deletes products via the Admin Import tool (see Mage_ImportExport_Model_Import_Entity_Product::_deleteProducts()) – STW Sep 30 at 19:38

The none code way

In the admin section under Manage Products would will find a grid with all your products. There is a column called SKU. Here you can filter your products based on the value.

sku filter

Then once you have filtered by SKU you can use the checkboxes on the left hand side to select all the items you wish to delete.

multiple select

Notice the select all which will select all items in the complete grid and select visible which will only select items on the current page of the grid.

Once you have selected the items you want you can use the mass action button on the top right hand side of the grid and select the delete option.

delete mass action

This will prompt you to make sure you a sure you want to delete these items. After selecting yes to this pop-up it will proceed to delete your items. Depending on your index settings you may have to run a re-index after this process.

share|improve this answer
And Select All works with terrifying efficiency. Accidentally choosing it without any sort of search constraints truly deletes everything in your product catalog, and once started, killing the server or running out of memory during the delete are the only things that stop it. – Fiasco Labs Jun 29 '14 at 15:09

You can do it programmatically. Here is the code

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.