Magento 2:顧客、製品、レビュー、注文の表を切り捨てる方法


34

Magento 2のすべてのテスト顧客、製品、レビュー、注文を削除するために切り捨てる必要があるテーブルのリストはありますか?私はテスト後クリアリングMagentoに似たものを探しています


これは、注文の削除に役立つはずですmagecomp.com/magento-2-delete-orders.html
Gaurav Jain

私は@amitshreeの答えからのすべてのクエリを使用しました。しかし、私はいくつかのテーブルがまだ多くのデータを持っているのを見ました:+ --------------------------------------- -------------------- + -------- + | テーブル| 行| + ------------------------------------------------- ---------- + -------- + | catalog_product_attribute_cl | 29613 | | catalogrule_product_cl | 31850 | | url_rewrite | 98607 | | sequence_product | 178345 | | targetrule_product_rule_cl | 1944 | | email_catalog | 99064 | | catalog_product_index_price_replica | 395031 | | cataloginventory_stock_status_replica | 56320 | | catalogsearch_fulltext_cl | 14524 | | catalog_product
Hoangnm

新しい質問がある場合は、「質問する」ボタンをクリックして質問してください。コンテキストの提供に役立つ場合は、この質問へのリンクを含めてください。- レビューから
ラマチャンドランM

回答:


72

[注]:これらのクエリを実行する前に、データベースのバックアップを作成してください。

すべてのテーブルを調べて、テストデータをクリアするために切り捨てる必要がある次のテーブルのリストを作成しました。

SET FOREIGN_KEY_CHECKS = 0;

オーダーテーブルの切り捨て

TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;
TRUNCATE TABLE `reporting_orders`;
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;
TRUNCATE TABLE `sales_creditmemo_grid`;
TRUNCATE TABLE `sales_creditmemo_item`;
TRUNCATE TABLE `sales_invoice`;
TRUNCATE TABLE `sales_invoiced_aggregated`;
TRUNCATE TABLE `sales_invoiced_aggregated_order`;
TRUNCATE TABLE `sales_invoice_comment`;
TRUNCATE TABLE `sales_invoice_grid`;
TRUNCATE TABLE `sales_invoice_item`;
TRUNCATE TABLE `sales_order`;
TRUNCATE TABLE `sales_order_address`;
TRUNCATE TABLE `sales_order_aggregated_created`;
TRUNCATE TABLE `sales_order_aggregated_updated`;
TRUNCATE TABLE `sales_order_grid`;
TRUNCATE TABLE `sales_order_item`;
TRUNCATE TABLE `sales_order_payment`;
TRUNCATE TABLE `sales_order_status_history`;
TRUNCATE TABLE `sales_order_tax`;
TRUNCATE TABLE `sales_order_tax_item`;
TRUNCATE TABLE `sales_payment_transaction`;
TRUNCATE TABLE `sales_refunded_aggregated`;
TRUNCATE TABLE `sales_refunded_aggregated_order`;
TRUNCATE TABLE `sales_shipment`;
TRUNCATE TABLE `sales_shipment_comment`;
TRUNCATE TABLE `sales_shipment_grid`;
TRUNCATE TABLE `sales_shipment_item`;
TRUNCATE TABLE `sales_shipment_track`;
TRUNCATE TABLE `sales_shipping_aggregated`;
TRUNCATE TABLE `sales_shipping_aggregated_order`;
TRUNCATE TABLE `tax_order_aggregated_created`;
TRUNCATE TABLE `tax_order_aggregated_updated`;

顧客テーブルの切り捨て

TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
TRUNCATE TABLE `wishlist`;
TRUNCATE TABLE `wishlist_item`;
TRUNCATE TABLE `wishlist_item_option`;

レビュー表の切り捨て

TRUNCATE TABLE `review`;
TRUNCATE TABLE `review_detail`;
TRUNCATE TABLE `review_entity_summary`;
TRUNCATE TABLE `review_store`;

製品テーブルの切り捨て

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;

1
テーブルをこのように切り捨てた後、私は取得SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (Magentoの.cataloginventory_stock_item , CONSTRAINT CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID` FOREIGN KEY(stock_id)REFERENCES cataloginventory_stockstock_idDELETE CASC ON))製品の保存/追加しようとして`エラーを。それはあなたのために働きますか?
トム

1
@Tom私もこのエラーに直面しました。cataloginventory_stockテーブルを切り捨てない場合、正常に機能します。
amitshree

これを試さないでください。グループ化された製品は、このクエリの実行後に作成されないためです。
サラヴァナベル

@saravanavelu:なぜそうですか?なぜテーブルが問題を作成するのですか?
amitshree

存在しない「位置」列で並べようとします。このクエリを実行した後、グループ化された製品を作成しようとしましたか?
サラヴァナベル

5

顧客の切り捨て

TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
DELETE FROM customer_address_entity WHERE 1;
TRUNCATE TABLE `catalog_compare_item`;
DELETE FROM customer_entity WHERE 1;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
DELETE FROM wishlist WHERE 1;
DELETE FROM wishlist_item WHERE 1;
TRUNCATE TABLE `wishlist_item_option`;

5

すべてのレビューをクリアする:

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `rating_option_vote`;
TRUNCATE TABLE `rating_option_vote_aggregated`;
TRUNCATE TABLE `review`;
TRUNCATE TABLE `review_detail`;
TRUNCATE TABLE `review_entity_summary`;
TRUNCATE TABLE `review_store`;

すべての顧客をクリアする:

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;

ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;

すべての製品の消去:

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
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_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
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_link_type`;
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_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `catalog_product_entity`;
INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `cataloginventory_stock`(`stock_id`,`website_id`,`stock_name`) VALUES (1,0,'Default');

すべての注文、出荷、取引などをクリアする:

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE `sales_order`;
TRUNCATE `sendfriend_log`;
TRUNCATE `wishlist`;
TRUNCATE `report_event`;

ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;

注文の増分IDは削除されません。
チラグ

3

カテゴリーの切り捨てとルートカテゴリーの作成

SET FOREIGN_KEY_CHECKS = 0;

TRUNCATE TABLE `catalog_category_entity`; 
TRUNCATE TABLE `catalog_category_entity_datetime`; 
TRUNCATE TABLE `catalog_category_entity_decimal`; 
TRUNCATE TABLE `catalog_category_entity_int`; 
TRUNCATE TABLE `catalog_category_entity_text`; 
TRUNCATE TABLE `catalog_category_entity_varchar`; 
TRUNCATE TABLE `catalog_category_product`; 
TRUNCATE TABLE `catalog_category_product_index`;

INSERT INTO `catalog_category_entity`(` entity_id`、 `attribute_set_id`、` parent_id`、 `created_at`、` updated_at`、 `path`、` position`、 `level`、` children_count`)VALUES( '1'、 '0 '、' 0 '、' 2016-06-23 00:00:00 '、' 2016-06-23 00:00:00 '、' 1 '、' 0 '、' 0 '、' 1 ')、( 「2」、「3」、「1」、「2016-06-23 00:00:00」、「2016-06-23 00:00:00」、「1/2」、「1」、「1 '、' 0 ');
INSERT INTO `catalog_category_entity_datetime`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)VALUES( '1'、 '58'、 '0'、 '1'、NULL)、(2、 58、0、2、NULL);
INSERT INTO `catalog_category_entity_decimal`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)値
(1、69、0、2、NULL);
INSERT INTO `catalog_category_entity_int`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)VALUES( '1'、 '66'、 '0'、 '1'、 '1')、( 2、43、0、2、1)、(3、50、0、2、NULL)、(4、51、0、2、1)、(5、66、0、2、1)、(6、 68、0、2、0);
INSERT INTO `catalog_category_entity_text`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)VALUES( '1'、 '64'、 '0'、 '1'、NULL)、(2、 64、0、2、NULL)、(3、44、0、2、NULL)、(4、47、0、2、NULL)、(5、48、0、2、NULL)、(6、61、 0、2、NULL);
INSERT INTO `catalog_category_entity_varchar`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)VALUES( '1'、 '42'、 '0'、 '1'、 'Root Catalog');
INSERT INTO `catalog_category_entity_varchar`(` value_id`、 `attribute_id`、` store_id`、 `entity_id`、` value`)VALUES(2、42、0、2、 'Default Category')、(3、46、0、2 、NULL)、(4、49、0、2、 'PRODUCTS')、(5、57、0、2、NULL)、(6、60、0、2、NULL)、(7、65、0、2 、NULL)、(8、113、0、2、「default-category」)、(9、114、0、2、NULL)、(10、143、0、2、NULL)、(11、145、0 、2、NULL)、(12、147、0、2、NULL);

SET FOREIGN_KEY_CHECKS = 1;

2

カテゴリーを切り捨てる

TRUNCATE TABLE `catalog_category_entity`; 
TRUNCATE TABLE `catalog_category_entity_datetime`; 
TRUNCATE TABLE `catalog_category_entity_decimal`; 
TRUNCATE TABLE `catalog_category_entity_int`; 
TRUNCATE TABLE `catalog_category_entity_text`; 
TRUNCATE TABLE `catalog_category_entity_varchar`; 
TRUNCATE TABLE `catalog_category_product`; 
TRUNCATE TABLE `catalog_category_product_index`;


INSERT  INTO `catalog_category_entity`(`entity_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,0,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1',1,0,1),(2,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0); 
INSERT  INTO `catalog_category_entity_int`(`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,32,0,2,1),(2,32,1,2,1); 
INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,31,0,1,'Root Catalog'),(2,33,0,1,'root-catalog'),(3,31,0,2,'Default Category'),(4,39,0,2,'PRODUCTS'),(5,33,0,2,'default-category');

2

catalog_product_link_attributeテーブルを切り捨てないでください。グループ化された製品の作成時に問題が発生します。それ以外は、@ amitshree https://magento.stackexchange.com/a/102995/14787に記載されているように、他のテーブルを切り捨てることができ ます

そのテーブルを既に切り捨てている場合は、次のようにレコードを挿入します。

INSERT INTO `catalog_product_link_attribute` VALUES (1,1,'position','int'),(2,4,'position','int'),(3,5,'position','int'),(4,3,'position','int'),(5,3,'qty','decimal');

2

この正しいもの

DELETE FROM catalog_product_entity;

Truncateを使用すると、自動インクリメント値もリセットされるため、新しいアイテムのIDが再び1から始まるため、Truncateを使用する方が適切です。
ジキ

[OK]を私は@Zikiしようとします
Gowthaman

2

ここにあるMagento 2.2.6は、bin / magento sampledata:removeの後にデータベースを消去する必要がありました。

簡単に言えば、上記の注文顧客レビュー用のSQL はまだ機能しています(追加することを忘れないでくださいALTER TABLE xxx AUTO_INCREMENT=1;)が、カテゴリ製品の一部を調整する必要がありました

私はこの新しい要約が他の誰にも役立つと信じています:

カテゴリー

SET FOREIGN_KEY_CHECKS = 0;

DELETE FROM `m_url_rewrite` WHERE `entity_type` = 'category';

TRUNCATE TABLE `m_catalog_category_entity`;
TRUNCATE TABLE `m_catalog_category_entity_datetime`;
TRUNCATE TABLE `m_catalog_category_entity_decimal`;
TRUNCATE TABLE `m_catalog_category_entity_int`;
TRUNCATE TABLE `m_catalog_category_entity_text`;
TRUNCATE TABLE `m_catalog_category_entity_varchar`;
TRUNCATE TABLE `m_catalog_category_flat_store_1`;
TRUNCATE TABLE `m_catalog_category_flat_store_2`;
TRUNCATE TABLE `m_catalog_category_product`;
TRUNCATE TABLE `m_catalog_category_product_index`;
TRUNCATE TABLE `m_catalog_category_product_index_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_store1`;
TRUNCATE TABLE `m_catalog_category_product_index_store1_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_store2`;
TRUNCATE TABLE `m_catalog_category_product_index_store2_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_tmp`;

ALTER TABLE `m_catalog_category_entity` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_flat_store_1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_flat_store_2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store1_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store2_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_tmp` AUTO_INCREMENT=1;

INSERT INTO `m_catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '1', '0', '0', '1'),
('2', '3', '1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '1/2', '1', '1', '0');
INSERT INTO `m_catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
('1', '69', '0', '1', '1'),
('2', '46', '0', '2', '1'),
('3', '69', '0', '2', '1');
INSERT INTO `m_catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
('1', '45', '0', '1', 'Root Catalog'),
('2', '45', '0', '2', 'Default Category'),
('3', '52', '0', '2', 'PRODUCTS');

SET FOREIGN_KEY_CHECKS = 1;

製品

SET FOREIGN_KEY_CHECKS = 0;

DELETE FROM `m_url_rewrite` WHERE `entity_type` = 'product';

TRUNCATE TABLE `m_cataloginventory_stock_item`;
TRUNCATE TABLE `m_cataloginventory_stock_status`;
TRUNCATE TABLE `m_cataloginventory_stock_status_idx`;
TRUNCATE TABLE `m_cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `m_cataloginventory_stock`;
TRUNCATE TABLE `m_catalog_category_product`;
TRUNCATE TABLE `m_catalog_category_product_index`;
TRUNCATE TABLE `m_catalog_category_product_index_tmp`;
TRUNCATE TABLE `m_catalog_compare_item`;
TRUNCATE TABLE `m_catalog_product_bundle_option`;
TRUNCATE TABLE `m_catalog_product_bundle_option_value`;
TRUNCATE TABLE `m_catalog_product_bundle_price_index`;
TRUNCATE TABLE `m_catalog_product_bundle_selection`;
TRUNCATE TABLE `m_catalog_product_bundle_selection_price`;
TRUNCATE TABLE `m_catalog_product_bundle_stock_index`;
TRUNCATE TABLE `m_catalog_product_entity_datetime`;
TRUNCATE TABLE `m_catalog_product_entity_decimal`;
TRUNCATE TABLE `m_catalog_product_entity_gallery`;
TRUNCATE TABLE `m_catalog_product_entity_int`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value_to_entity`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value_video`;
TRUNCATE TABLE `m_catalog_product_entity_text`;
TRUNCATE TABLE `m_catalog_product_entity_tier_price`;
TRUNCATE TABLE `m_catalog_product_entity_varchar`;
TRUNCATE TABLE `m_catalog_product_link`;
TRUNCATE TABLE `m_catalog_product_link_attribute`;
TRUNCATE TABLE `m_catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `m_catalog_product_link_attribute_int`;
TRUNCATE TABLE `m_catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `m_catalog_product_link_type`;
TRUNCATE TABLE `m_catalog_product_option`;
TRUNCATE TABLE `m_catalog_product_option_price`;
TRUNCATE TABLE `m_catalog_product_option_title`;
TRUNCATE TABLE `m_catalog_product_option_type_price`;
TRUNCATE TABLE `m_catalog_product_option_type_title`;
TRUNCATE TABLE `m_catalog_product_option_type_value`;
TRUNCATE TABLE `m_catalog_product_super_attribute`;
TRUNCATE TABLE `m_catalog_product_super_attribute_label`;
TRUNCATE TABLE `m_catalog_product_super_link`;
TRUNCATE TABLE `m_catalog_product_index_eav`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_idx`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_replica`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_tmp`;
TRUNCATE TABLE `m_catalog_product_index_eav_idx`;
TRUNCATE TABLE `m_catalog_product_index_eav_replica`;
TRUNCATE TABLE `m_catalog_product_index_eav_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_sel_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_sel_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_agr_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_agr_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_downlod_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_downlod_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_final_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_final_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_agr_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_agr_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_replica`;
TRUNCATE TABLE `m_catalog_product_index_price_tmp`;
TRUNCATE TABLE `m_catalog_product_index_tier_price`;
TRUNCATE TABLE `m_catalog_product_index_website`;
TRUNCATE TABLE `m_catalog_product_website`;
TRUNCATE TABLE `m_catalog_product_flat_1`;
TRUNCATE TABLE `m_catalog_product_flat_2`;
TRUNCATE TABLE `m_catalog_product_relation`;
TRUNCATE TABLE `m_catalog_product_frontend_action`;
TRUNCATE TABLE `m_catalog_url_rewrite_product_category`;
TRUNCATE TABLE `m_downloadable_link`;
TRUNCATE TABLE `m_downloadable_link_price`;
TRUNCATE TABLE `m_downloadable_link_purchased`;
TRUNCATE TABLE `m_downloadable_link_purchased_item`;
TRUNCATE TABLE `m_downloadable_link_title`;
TRUNCATE TABLE `m_downloadable_sample`;
TRUNCATE TABLE `m_downloadable_sample_title`;
TRUNCATE TABLE `m_product_alert_price`;
TRUNCATE TABLE `m_product_alert_stock`;
TRUNCATE TABLE `m_report_compared_product_index`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_daily`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_monthly`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_yearly`;
TRUNCATE TABLE `m_report_viewed_product_index`;
TRUNCATE TABLE `m_catalog_product_entity`;

ALTER TABLE `m_cataloginventory_stock_item` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_compare_item` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_option` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_option_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_price_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_selection` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_selection_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_stock_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_gallery` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value_to_entity` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value_video` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_tier_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_type` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_title` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_title` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_attribute` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_attribute_label` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_link` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_sel_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_sel_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_agr_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_agr_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_downlod_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_downlod_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_final_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_final_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_agr_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_agr_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_tier_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_website` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_website` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_flat_1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_flat_2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_relation` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_frontend_action` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_url_rewrite_product_category` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_price` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_purchased` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_purchased_item` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_title` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_sample` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_sample_title` AUTO_INCREMENT=1;
ALTER TABLE `m_product_alert_price` AUTO_INCREMENT=1;
ALTER TABLE `m_product_alert_stock` AUTO_INCREMENT=1;
ALTER TABLE `m_report_compared_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_daily` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_monthly` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_yearly` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity` AUTO_INCREMENT=1;

INSERT  INTO `m_catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `m_catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `m_cataloginventory_stock`(`stock_id`,`website_id`,`stock_name`) VALUES (1,0,'Default');

SET FOREIGN_KEY_CHECKS = 1;

1

カテゴリテーブルを切り捨てた後、URLキーの重複エントリエラーが発生する可能性があるため、url_rewriteテーブルからカテゴリURLキーをクリアする必要があります。

DELETE FROM `url_rewrite` WHERE `entity_type` = 'category'

1

みんなの答えは素晴らしいですが、これらのテーブルが切り捨てられたときに自動インクリメントがリセットされることは重要です。通常、MySQLはこれを自動的に行いますが、2つの異なる環境では、リセットされないという無数の問題がありました。REGEXを使用して上記の回答を見つけて置き換え、各TRUNCATEの後にALTER TABLEを追加しました。上記の症状/問題のほとんどは、切り捨てられたすべてのテーブルでAUTO_INCREMENTSをリセットするまで見られました。


0

データベースからユーザーの詳細を消去するには、次の手順を実行できます。

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
TRUNCATE TABLE `wishlist`;
TRUNCATE TABLE `wishlist_item`;
TRUNCATE TABLE `wishlist_item_option`;
SET FOREIGN_KEY_CHECKS = 1;

これにより、すべてのユーザーが削除され、エンティティIDが1から始まります。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.