0

I have multiple products that I need to delete from magento. Found this thread Delete multiple products in Magento and tried both scripts, however when I load mysite.com/script.php I get http error 500.

Both php and CSV files are in root directory. in the script I have changed filenames to match csv file and also corrected the path to mage app accordingly.

Any suggestions?

2 Answers 2

2

Best option would be running sql script from phpmyadmin or as sql as @Marius suggested.

Go to your database (phpmyadmin) and run this script.

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

add all your other sku. Please make backup of your database before doing so.

But if you wish to do it through magento then follow @Doug McLean solution:

Create a csv file having all your sku, 1 in each row, having sku in first row.

Then go to System > Import/Export > Import then in import page choose Import Behavior to "Delete Entities" and upload the file and proceed.

enter image description here

Then clear the cache.

1
  • suppose if i want to delete products from the selected store, what is my CSV format.
    – zus
    Commented Dec 21, 2017 at 7:20
1

Please try these following step according your requirement.

Solution 1 :- To delete all products you can use this query:

    SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;

TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;

INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
SET FOREIGN_KEY_CHECKS = 1;

> Solution 2 :- To delete some select products you can use this:-

In order to delete products, you can simply use backend:

Catalog > Manage Products > Select all checboxes and choose Action = Delete and hit submit.

This may work very good for some thousands of products.

> Go to System -> Index Management, select and Re-index,after clear cache

Hope It's helpful for any one.

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.