Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Truncate all products from Magento 2
SET FOREIGN_KEY_CHECKS = 0;
-- truncate products
TRUNCATE TABLE `PREFIX_cataloginventory_stock_item`;
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status`;
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status_idx`;
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `PREFIX_catalog_category_product`;
TRUNCATE TABLE `PREFIX_catalog_category_product_index`;
TRUNCATE TABLE `PREFIX_catalog_category_product_index_tmp`;
TRUNCATE TABLE `PREFIX_catalog_compare_item`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_option`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_option_value`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_price_index`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_selection`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_selection_price`;
TRUNCATE TABLE `PREFIX_catalog_product_bundle_stock_index`;
TRUNCATE TABLE `PREFIX_catalog_product_entity`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_datetime`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_decimal`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_gallery`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_int`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_media_gallery`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_media_gallery_value_to_entity`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_media_gallery_value_video`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_text`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_tier_price`;
TRUNCATE TABLE `PREFIX_catalog_product_entity_varchar`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav_decimal`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav_decimal_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav_decimal_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_eav_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_opt_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_opt_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_sel_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_sel_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_bundle_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_cfg_opt_agr_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_cfg_opt_agr_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_cfg_opt_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_cfg_opt_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_downlod_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_downlod_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_final_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_final_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_opt_agr_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_opt_agr_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_opt_idx`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_opt_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_price_tmp`;
TRUNCATE TABLE `PREFIX_catalog_product_index_tier_price`;
TRUNCATE TABLE `PREFIX_catalog_product_index_website`;
TRUNCATE TABLE `PREFIX_catalog_product_link`;
TRUNCATE TABLE `PREFIX_catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `PREFIX_catalog_product_link_attribute_int`;
TRUNCATE TABLE `PREFIX_catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `PREFIX_catalog_product_option`;
TRUNCATE TABLE `PREFIX_catalog_product_option_price`;
TRUNCATE TABLE `PREFIX_catalog_product_option_title`;
TRUNCATE TABLE `PREFIX_catalog_product_option_type_price`;
TRUNCATE TABLE `PREFIX_catalog_product_option_type_title`;
TRUNCATE TABLE `PREFIX_catalog_product_option_type_value`;
TRUNCATE TABLE `PREFIX_catalog_product_relation`;
TRUNCATE TABLE `PREFIX_catalog_product_super_attribute`;
TRUNCATE TABLE `PREFIX_catalog_product_super_attribute_label`;
TRUNCATE TABLE `PREFIX_catalog_product_super_link`;
TRUNCATE TABLE `PREFIX_catalog_product_website`;
TRUNCATE TABLE `PREFIX_catalog_url_rewrite_product_category`;
TRUNCATE TABLE `PREFIX_downloadable_link`;
TRUNCATE TABLE `PREFIX_downloadable_link_price`;
TRUNCATE TABLE `PREFIX_downloadable_link_purchased`;
TRUNCATE TABLE `PREFIX_downloadable_link_purchased_item`;
TRUNCATE TABLE `PREFIX_downloadable_link_title`;
TRUNCATE TABLE `PREFIX_downloadable_sample`;
TRUNCATE TABLE `PREFIX_downloadable_sample_title`;
TRUNCATE TABLE `PREFIX_product_alert_price`;
TRUNCATE TABLE `PREFIX_product_alert_stock`;
TRUNCATE TABLE `PREFIX_report_compared_product_index`;
TRUNCATE TABLE `PREFIX_report_viewed_product_aggregated_daily`;
TRUNCATE TABLE `PREFIX_report_viewed_product_aggregated_monthly`;
TRUNCATE TABLE `PREFIX_report_viewed_product_aggregated_yearly`;
TRUNCATE TABLE `PREFIX_report_viewed_product_index`;
SET FOREIGN_KEY_CHECKS = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment