How To Remove Categories and Products in Magento 2.x

While working Magento 2 development / design, once project completed & going to production , before that need to remove all catalog [Remove All Categories Data, All Products Data].

The following below SQL Query need to run.

SET FOREIGN_KEY_CHECKS = 0;
 
TRUNCATE TABLE cataloginventory_stock_item;
TRUNCATE TABLE cataloginventory_stock_status;
TRUNCATE TABLE cataloginventory_stock_status_idx;
TRUNCATE TABLE cataloginventory_stock_status_tmp;
TRUNCATE TABLE catalog_category_product;
TRUNCATE TABLE catalog_category_product_index;
TRUNCATE TABLE catalog_category_product_index_tmp;
TRUNCATE TABLE catalog_compare_item;
TRUNCATE TABLE catalog_product_bundle_option;
TRUNCATE TABLE catalog_product_bundle_option_value;
TRUNCATE TABLE catalog_product_bundle_price_index;
TRUNCATE TABLE catalog_product_bundle_selection;
TRUNCATE TABLE catalog_product_bundle_selection_price;
TRUNCATE TABLE catalog_product_bundle_stock_index;
TRUNCATE TABLE catalog_product_entity;
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_media_gallery_value_to_entity;
TRUNCATE TABLE catalog_product_entity_media_gallery_value_video;
TRUNCATE TABLE catalog_product_entity_text;
TRUNCATE TABLE catalog_product_entity_tier_price;
TRUNCATE TABLE catalog_product_entity_varchar;
TRUNCATE TABLE catalog_product_index_eav;
TRUNCATE TABLE catalog_product_index_eav_decimal;
TRUNCATE TABLE catalog_product_index_eav_decimal_idx;
TRUNCATE TABLE catalog_product_index_eav_decimal_tmp;
TRUNCATE TABLE catalog_product_index_eav_idx;
TRUNCATE TABLE catalog_product_index_eav_tmp;
TRUNCATE TABLE catalog_product_index_price;
TRUNCATE TABLE catalog_product_index_price_bundle_idx;
TRUNCATE TABLE catalog_product_index_price_bundle_opt_idx;
TRUNCATE TABLE catalog_product_index_price_bundle_opt_tmp;
TRUNCATE TABLE catalog_product_index_price_bundle_sel_idx;
TRUNCATE TABLE catalog_product_index_price_bundle_sel_tmp;
TRUNCATE TABLE catalog_product_index_price_bundle_tmp;
TRUNCATE TABLE catalog_product_index_price_cfg_opt_agr_idx;
TRUNCATE TABLE catalog_product_index_price_cfg_opt_agr_tmp;
TRUNCATE TABLE catalog_product_index_price_cfg_opt_idx;
TRUNCATE TABLE catalog_product_index_price_cfg_opt_tmp;
TRUNCATE TABLE catalog_product_index_price_downlod_idx;
TRUNCATE TABLE catalog_product_index_price_downlod_tmp;
TRUNCATE TABLE catalog_product_index_price_final_idx;
TRUNCATE TABLE catalog_product_index_price_final_tmp;
TRUNCATE TABLE catalog_product_index_price_idx;
TRUNCATE TABLE catalog_product_index_price_opt_agr_idx;
TRUNCATE TABLE catalog_product_index_price_opt_agr_tmp;
TRUNCATE TABLE catalog_product_index_price_opt_idx;
TRUNCATE TABLE catalog_product_index_price_opt_tmp;
TRUNCATE TABLE catalog_product_index_price_tmp;
TRUNCATE TABLE catalog_product_index_tier_price;
TRUNCATE TABLE catalog_product_index_website;
TRUNCATE TABLE catalog_product_link;
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_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_relation;
TRUNCATE TABLE catalog_product_super_attribute;
TRUNCATE TABLE catalog_product_super_attribute_label;
TRUNCATE TABLE catalog_product_super_link;
TRUNCATE TABLE catalog_product_website;
TRUNCATE TABLE catalog_url_rewrite_product_category;
TRUNCATE TABLE downloadable_link;
TRUNCATE TABLE downloadable_link_price;
TRUNCATE TABLE downloadable_link_purchased;
TRUNCATE TABLE downloadable_link_purchased_item;
TRUNCATE TABLE downloadable_link_title;
TRUNCATE TABLE downloadable_sample;
TRUNCATE TABLE downloadable_sample_title;
TRUNCATE TABLE product_alert_price;
TRUNCATE TABLE product_alert_stock;
TRUNCATE TABLE report_compared_product_index;
TRUNCATE TABLE report_viewed_product_aggregated_daily;
TRUNCATE TABLE report_viewed_product_aggregated_monthly;
TRUNCATE TABLE report_viewed_product_aggregated_yearly;
TRUNCATE TABLE report_viewed_product_index;
 
SET FOREIGN_KEY_CHECKS = 1;

Once above query run, Finally all Catalog Data will be removed / deleted.

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

Leave a Reply

Your email address will not be published. Required fields are marked *