i am a newbie in magento so dont know much about coding and scrippts,

my problem is i have list of SKU's which are end of line now and has been replaced with new products.

i want to delete them so i can free up some space for new products. but doing around 5k of products manually are taking way too much long. is there any way i can delete them in bulk using .CSV or XML import export or dataFlow service?

i am new to all this magento so please if you know the answer tell me in details that which code where exactly need to place.

thank you guys. i hope some one will be able to help.


4 Answers 4


I don't believe dataflow will let you delete product - but you could go that route to set specified products to "Disabled".

You could then filter products by status and batch delete them via admin -OR- you could programmatically delete them similar to what's shown below (obviously, you'd want to add a foreach loop and probably switch $product_id to a $product_ids array - another caveat: this snippit assumes the Mage::App() is initialized):

<?php Mage::register("isSecureArea", 1);
$product_id = 2; //use your own product id 
Mage::getModel("catalog/product")->load( $product_id  )->delete(); 
catch(Exception $e){
echo "Delete failed";
} ?>

I would thoroughly recommend to use Magmi to do this:


Easy to install and configure, and will blast through the deletion of 5000 products in under 15 seconds.

You can export from your products grid all of the products you want to delete. You simply need to create a csv file with the SKU only of the products you want to remove. And another header labelled "magmi:delete"

The value of 1 in the corresponding cells will delete that product.

Ensure you select the Product Deleter v0.0.2 plugin from the configurable options in your Magmi settings before running the profile.

Great answer here already from this site on how to do in a bit more depth:

How do I delete products in magmi

Hoping this helps?


Just create a file with all the skus that you want to delete and execute this code

require_once('/app/Mage.php'); //Path to Magento
$f = file( "delete-sku.txt");
foreach ($f as $line_num => $sku) { 
    echo $sku . "\n";    
    $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);

Click Here to add MAGMI into your module -> https://magento.stackexchange.com/a/351175

Enable Product Deleter plugin.

enter image description here

Using CSV


Using Code

    $importData = [];
    $configProduct = new \Magmi_ProductImport_DataPump('productimport');
    $importData['sku'] = "your Product SKU";
    $importData['magmi:delete'] = "1";
    $configProduct->beginImportSession("default", "update");
    $run = $configProduct->ingest($importData);

Check catalog_eav_attribute table in your db . If is_configurable column not present then update below code from getConfigurableOptsFromAsId() function in this file .../magmi/plugins/base/itemprocessors/configurables/magmi_configurableprocessor.php

    //$sql .= " JOIN $cea as cea ON cea.attribute_id=ea.attribute_id AND cea.is_global=1 AND cea.is_configurable=1";
    $sql .= " JOIN $cea as cea ON cea.attribute_id=ea.attribute_id AND cea.is_global=1";
} else {
    //$cond .= " AND ea.is_global=1 AND ea.is_configurable=1";
    $cond .= " AND ea.is_global=1";

Note:- magmi:delete : 1 is to delete the product 0 is to not delete the product

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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