Magento 2: come troncare tabella clienti, prodotti, recensioni e ordini


34

Qualcuno ha un elenco di tabelle che devo troncare per eliminare tutti i clienti, i prodotti, le recensioni e gli ordini di prova in Magento 2? Sto cercando qualcosa di simile a Clearing Magento dopo il test .


Questo dovrebbe aiutare per la cancellazione dell'ordine magecomp.com/magento-2-delete-orders.html
Gaurav Jain,

ho appena usato tutte le domande dalla risposta di @ amitshree. Ma ho visto che alcuni tavoli contengono ancora molti dati: + --------------------------------------- -------------------- + -------- + | Tabella | Righe | + ------------------------------------------------- ---------- + -------- + | catalog_product_attribute_cl | 29613 | | catalogrule_product_cl | 31850 | | url_rewrite | 98607 | | sequenza_prodotto | 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,

Se hai una nuova domanda, chiedila facendo clic sul pulsante Poni domanda . Includi un link a questa domanda se aiuta a fornire un contesto. - Dalla recensione
Rama Chandran M,

Risposte:


72

[Nota] : eseguire il backup del database prima di eseguire queste query.

Ho esaminato tutte le tabelle e ho creato il seguente elenco di tabelle che devono essere troncate per cancellare i dati di test:

SET FOREIGN_KEY_CHECKS = 0;

Tronca le tabelle degli ordini

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`;

Tronca le tabelle dei clienti

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`;

Troncare le tabelle di revisione

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

Tronca le tabelle dei prodotti

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
Dopo troncare le tabelle in questo modo, ottengo un 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) RIFERIMENTI cataloginventory_stock( stock_id) ON CASC DELETE) `errore quando si tenta di aggiungere / Salva prodotto. Per te funziona?
Tom,

1
@Tom Ho riscontrato anche questo errore. Se non tronchi la cataloginventory_stocktabella funzionerà bene.
entro il

Non provare questo. perché il prodotto raggruppato non verrà creato dopo aver eseguito questa query.
saravanavelu,

@saravanavelu: perché così? perché la tabella creerà il problema?
entro il

Cerca di ordinare per colonna 'position', che non esiste. Hai provato a creare un prodotto raggruppato dopo aver eseguito questa query?
saravanavelu,

5

TRUNCARE I CLIENTI

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

Cancella tutte le recensioni:

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`;

Cancellare tutti i clienti:

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;

Cancellare tutti i prodotti:

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');

Annullamento di tutti gli ordini, spedizioni, transazioni ecc .:

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;

Non rimuove l'ID dell'incremento dell'ordine.
Chirag,

3

TRUNCARE LE CATEGORIE E CREARE UNA CATEGORIA DI RADICE

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`;

INSERISCI IN `catalog_category_entity` (` entity_id`, `attributi_set_id`,` parent_id`, `Created_at`,` updated_at`, `path`,` position`, `level`,` children_count`) VALUES ('1', '0 ',' 0 ',' 23/06/2016 00:00:00 ',' 23/06/2016 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 ');
INSERISCI IN `catalog_category_entity_datetime` (` value_id`, `attributo_id`,` store_id`, `entity_id`,` value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
INSERISCI IN `catalog_category_entity_decimal` (` value_id`, `attributo_id`,` store_id`, `entity_id`,` value`) VALORI
(1, 69, 0, 2, NULL);
INSERIRE `catalog_category_entity_int` (` value_id`, `attributo_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);
INSERISCI IN `catalog_category_entity_text` (` value_id`, `attributo_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);
INSERISCI IN `catalog_category_entity_varchar` (` value_id`, `attributo_id`,` store_id`, `entity_id`,` value`) VALUES ('1', '42', '0', '1', 'Catalog root');
INSERISCI IN `catalog_category_entity_varchar` (` value_id`, `attributo_id`,` store_id`, `entity_id`,` valore`) VALORI (2, 42, 0, 2, 'Categoria predefinita'), (3, 46, 0, 2 , NULL), (4, 49, 0, 2, "PRODOTTI"), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2 , NULL), (8, 113, 0, 2, 'categoria predefinita'), (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

CATEGORIE TRUNCATE

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

Non troncare la catalog_product_link_attributetabella, altrimenti si verificherà un problema durante la creazione di prodotti raggruppati. Tranne quello, puoi troncare altre tabelle come menzionato da @amitshree https://magento.stackexchange.com/a/102995/14787

Se hai già troncato quella tabella, inserisci i record come di seguito: -

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

Questo corretto

DELETE FROM catalog_product_entity;

L'uso di Tronca è migliore perché reimposta anche il valore di incremento automatico, quindi i nuovi elementi avranno i loro ID a partire da 1 di nuovo.
Ziki

ok proverò @Ziki
Gowthaman il

2

Magento 2.2.6 qui, ha dovuto pulire il database dopo un sampledata bin / magento: rimuovere.

Per farla breve, SQL sopra per gli ordini , i clienti e le recensioni funzionano ancora (ricordati di aggiungere ALTER TABLE xxx AUTO_INCREMENT=1;) ma ho dovuto modificare alcune cose per categorie e prodotti .

Credo che questo nuovo riassunto possa aiutare chiunque altro:

CATEGORIE

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;

PRODOTTI

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

Dopo aver troncato le tabelle delle categorie, è possibile che vengano visualizzati errori di immissione duplicati per le chiavi URL, pertanto è necessario cancellare le chiavi URL categoria dalla url_rewritetabella.

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

1

Le risposte di tutti sono ottime, ma vorrei aggiungere che è CRITICO che gli Incrementi automatici vengano ripristinati quando queste tabelle vengono troncate. Normalmente MySQL lo fa automaticamente, ma in due ambienti separati, ho avuto innumerevoli problemi con questo NON essere ripristinato. Ho usato REGEX per trovare e sostituire le risposte di cui sopra per aggiungere una tabella ALTER dopo ogni TRUNCATE. La maggior parte dei suddetti sintomi / problemi sono stati rilevati fino a quando non ho ripristinato AUTO_INCREMENTS su tutte le tabelle troncate.


0

Per cancellare i dettagli dell'utente dal database è possibile eseguire i passaggi seguenti.

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;

Ciò rimuoverà tutti gli utenti e avvierà l'ID entità da 1.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.