Magento – How to delete all products from a large catalog

magento-enterpriseproducts-management

I'm working on importing ~40k products into Magento. I need an easy way to remove all products in between tests, but trying to do this from the admin errors out before making it very far.

If I try to truncate the table's directly, I encounter a lot of dependencies that prevent the actions.

Is it possible to erase all products without using the admin?

Best Answer

If you are importing via Mage_ImportExport there is also an option "DELETE". If you apply this on the same import file, all SKUs contained in this file will be deleted.

In code this is ->setBehavior(Mage_ImportExport_Model_Import::BEHAVIOR_DELETE);

You still can truncate the specific product tables via SQL - but of course you have to resolve all the dependencies and also truncate those tables.

Or: Create a "clean" database dump before importing and apply this dump before each test.