2

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.

3

Use Magmi so that you can do this by without any coding. Also product adding will be much easier and faster

http://www.adrikodde.nl/blog/2013/how-delete-magento-products-magmi/

2

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 
try{
Mage::getModel("catalog/product")->load( $product_id  )->delete(); 
}
catch(Exception $e){
echo "Delete failed";
} ?>
1

I would thoroughly recommend to use Magmi to do this:

http://sourceforge.net/projects/magmi/

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?

1

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
umask(0);
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); 
$f = file( "delete-sku.txt");
foreach ($f as $line_num => $sku) { 
    echo $sku . "\n";    
    $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
    $product->delete();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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