Skip to content

Instantly share code, notes, and snippets.

@emtii
Last active January 27, 2017 14:00
Show Gist options
  • Save emtii/1a2d1b1bba522770c0b4ca2d58654aee to your computer and use it in GitHub Desktop.
Save emtii/1a2d1b1bba522770c0b4ca2d58654aee to your computer and use it in GitHub Desktop.
Deletes Articles from Shopware 5.2.8
Description
====================================================================================================================
We basically need 2 steps to completely remove articles, categories & suppliers from this shopware version:
1. truncate mysql tables
2. use sw cli command to remove left images from filesystem
1. truncate
====================================================================================================================
SET foreign_key_checks = 0;
DELETE FROM `s_categories` WHERE id != 1 OR id != 3;
TRUNCATE `s_categories_attributes`;
TRUNCATE `s_categories_avoid_customergroups`;
TRUNCATE `s_addon_premiums`;
TRUNCATE `s_article_configurator_dependencies`;
TRUNCATE `s_article_configurator_groups`;
TRUNCATE `s_article_configurator_option_relations`;
TRUNCATE `s_article_configurator_options`;
TRUNCATE `s_article_configurator_price_variations`;
TRUNCATE `s_article_configurator_set_group_relations`;
TRUNCATE `s_article_configurator_set_option_relations`;
TRUNCATE `s_article_configurator_sets`;
TRUNCATE `s_article_configurator_template_prices`;
TRUNCATE `s_article_configurator_template_prices_attributes`;
TRUNCATE `s_article_configurator_templates`;
TRUNCATE `s_article_configurator_templates_attributes`;
TRUNCATE `s_article_img_mapping_rules`;
TRUNCATE `s_article_img_mappings`;
TRUNCATE `s_articles`;
TRUNCATE `s_articles_also_bought_ro`;
TRUNCATE `s_articles_attributes`;
TRUNCATE `s_articles_avoid_customergroups`;
TRUNCATE `s_articles_categories`;
TRUNCATE `s_articles_categories_ro`;
TRUNCATE `s_articles_categories_seo`;
TRUNCATE `s_articles_details`;
TRUNCATE `s_articles_downloads`;
TRUNCATE `s_articles_downloads_attributes`;
TRUNCATE `s_articles_esd`;
TRUNCATE `s_articles_esd_attributes`;
TRUNCATE `s_articles_esd_serials`;
TRUNCATE `s_articles_img`;
TRUNCATE `s_articles_img_attributes`;
TRUNCATE `s_articles_information`;
TRUNCATE `s_articles_information_attributes`;
TRUNCATE `s_articles_notification`;
TRUNCATE `s_articles_prices`;
TRUNCATE `s_articles_prices_attributes`;
TRUNCATE `s_articles_relationships`;
TRUNCATE `s_articles_similar`;
TRUNCATE `s_articles_similar_shown_ro`;
TRUNCATE `s_articles_supplier`;
TRUNCATE `s_articles_supplier_attributes`;
TRUNCATE `s_articles_top_seller_ro`;
TRUNCATE `s_articles_translations`;
TRUNCATE `s_articles_vote`;
TRUNCATE `s_filter`;
TRUNCATE `s_filter_articles`;
TRUNCATE `s_filter_attributes`;
TRUNCATE `s_filter_options`;
TRUNCATE `s_filter_options_attributes`;
TRUNCATE `s_filter_relations`;
TRUNCATE `s_filter_values`;
TRUNCATE `s_filter_values_attributes`;
DELETE FROM `s_media` WHERE `albumID` = -1;
DELETE FROM `s_core_translations` WHERE objecttype IN ('article', 'variant');
SET foreign_key_checks = 1;
2. cli command
====================================================================================================================
php bin/console sw:media:cleanup --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment