Removing products and categories from the database

Last modified by brendanb on Fri, June 25, 2010 09:52
Source|Old Revisions  

This is an old revision of the document!


=====Update to Removing products through the database=====

Ive used the following to remove all product records and related data from the mySQL tables.

  1. TRUNCATE TABLE `cataloginventory_stock_item`;
  2. TRUNCATE TABLE `catalogindex_minimal_price`;
  3. TRUNCATE TABLE `catalog_product_entity`;
  4. TRUNCATE TABLE `catalog_product_entity_datetime`;
  5. TRUNCATE TABLE `catalog_product_entity_decimal`;
  6. TRUNCATE TABLE `catalog_product_entity_int`;
  7. TRUNCATE TABLE `catalog_product_entity_text`;
  8. TRUNCATE TABLE `catalog_product_entity_varchar`;
  9. TRUNCATE TABLE `catalog_category_product`;
  10. TRUNCATE TABLE `catalog_category_product_index`;
  11. TRUNCATE TABLE `catalog_compare_item`;
  12. TRUNCATE TABLE `catalog_product_bundle_option`;
  13. TRUNCATE TABLE `catalog_product_bundle_option_value`;
  14. TRUNCATE TABLE `catalog_product_bundle_selection`;
  15. TRUNCATE TABLE `catalog_product_enabled_index`;
  16. TRUNCATE TABLE `catalog_product_entity`;
  17. TRUNCATE TABLE `catalog_product_entity_gallery`;
  18. TRUNCATE TABLE `catalog_product_entity_media_gallery`;
  19. TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
  20. TRUNCATE TABLE `catalog_product_entity_tier_price`;
  21. TRUNCATE TABLE `catalog_product_link`;
  22. TRUNCATE TABLE `catalog_product_link_attribute`;
  23. TRUNCATE TABLE `catalog_product_link_attribute_int`;
  24. TRUNCATE TABLE `catalog_product_website`;
  25. TRUNCATE TABLE `catalog_compare_item`;

Note: Tested this also by re-importing data back into tables. Worked fine

Removing products through the database

This should remove all the products and their related records.

  1. TRUNCATE TABLE `catalog_product_entity`;

Removing categories requires bit more actions.

  1. TRUNCATE TABLE `catalog_category_entity`;
  2. DELETE FROM `catalog_category_tree` WHERE `entity_id`<>1;

After that you will have to create root categories for your stores and assign them to stores in configuration:

admin menu / system / configuration / catalog - choose a store, choose Root Category.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs