Magento 2: cómo truncar clientes, productos, reseñas y tabla de pedidos


34

¿Alguien tiene una lista de tablas que necesito truncar para eliminar todos los clientes de prueba, productos, reseñas y pedidos en Magento 2? Estoy buscando algo similar a Clearing Magento después de las pruebas .


Esto debería ayudar para la eliminación de pedidos magecomp.com/magento-2-delete-orders.html
Gaurav Jain

Acabo de utilizar todas las consultas de la respuesta de @ amitshree. Pero vi que algunas tablas todavía tienen muchos datos: + --------------------------------------- -------------------- + -------- + | Tabla | Filas | + ------------------------------------------------- ---------- + -------- + | catalog_product_attribute_cl | 29613 | El | catalogrule_product_cl | 31850 | El | url_rewrite | 98607 | El | secuencia_producto | 178345 | El | targetrule_product_rule_cl | 1944 El | email_catalog | 99064 | El | catalog_product_index_price_replica | 395031 | El | cataloginventory_stock_status_replica | 56320 | El | catalogsearch_fulltext_cl | 14524 | El | catalog_product
Hoangnm

Si tiene una nueva pregunta, hágala haciendo clic en el botón Hacer pregunta . Incluya un enlace a esta pregunta si ayuda a proporcionar contexto. - De la opinión
Rama Chandran M

Respuestas:


72

[Nota] : realice una copia de seguridad de la base de datos antes de ejecutar estas consultas.

Revisé todas las tablas y se me ocurrió la siguiente lista de tablas que deberían truncarse para borrar los datos de prueba:

SET FOREIGN_KEY_CHECKS = 0;

Truncar tablas de pedidos

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

Truncar tablas de clientes

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

Truncar tablas de revisión

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

Truncar tablas de productos

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
Después de truncar las tablas de esta manera, consigo 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) Referencias cataloginventory_stock( stock_id) EN CASC eliminar) `error al intentar añadir / Guardar producto. ¿Funciona para ti?
Tom

1
@ Tom también me he enfrentado a este error. Si no trunca la cataloginventory_stocktabla, funcionará bien.
amitshree

No intentes esto. porque el producto agrupado no se creará después de ejecutar esta consulta.
saravanavelu

@saravanavelu: ¿por qué? ¿Por qué la tabla creará el problema?
amitshree

Intenta ordenar por columna 'posición', que no existe. ¿Intentó crear un producto agrupado después de ejecutar esta consulta?
saravanavelu

5

CLIENTES TRUNCADOS

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

Borrar todas las reseñas:

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

Liquidación de todos los clientes:

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;

Borrar todos los productos:

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

Liquidación de todos los pedidos, envíos, transacciones, etc.

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;

No está eliminando el ID de incremento de orden.
chirag

3

TRUNCAR CATEGORÍAS Y CREAR UNA CATEGORÍA RAÍZ

SET FOREIGN_KEY_CHECKS = 0;

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

INSERTAR EN `catalog_category_entity` (` entity_id`, `attribute_set_id`,` parent_id`, `created_at`,` updated_at`, `updated`at` 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 ');
INSERTAR EN `catalog_category_entity_datetime` (` value_id`, `attribute_id`,` store_id`, `entity_id`,` value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
INSERTAR EN `catalog_category_entity_decimal` (` value_id`, `attribute_id`,` store_id`, `entity_id`,` value`) VALUES
(1, 69, 0, 2, NULL);
INSERTAR EN `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);
INSERTAR EN `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);
INSERTAR EN `catalog_category_entity_varchar` (` value_id`, `attribute_id`,` store_id`, `entity_id`,` value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
INSERTAR EN `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, 'PRODUCTOS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2 , NULL), (8, 113, 0, 2, 'categoría predeterminada'), (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

CATEGORÍAS TRUNCADAS

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

No trunque la catalog_product_link_attributetabla, de lo contrario encontrará un problema al crear productos agrupados. Excepto eso, puede truncar otras tablas como lo menciona @amitshree https://magento.stackexchange.com/a/102995/14787

Si ya ha truncado esa tabla, inserte los registros de la siguiente manera: -

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

Esta correcta

DELETE FROM catalog_product_entity;

Usar Truncar es mejor porque también restablece el valor de incremento automático, por lo que sus nuevos elementos tendrán sus ID a partir de 1 nuevamente.
Ziki

ok intentaré @Ziki
Gowthaman

2

Magento 2.2.6 aquí, tuvo que limpiar la base de datos después de un bin / magento sampledata: eliminar.

En pocas palabras, el SQL anterior para pedidos , clientes y reseñas aún funciona (recuerde agregar ALTER TABLE xxx AUTO_INCREMENT=1;), pero tuve que modificar algunas cosas para categorías y productos .

Creo que este nuevo resumen puede ayudar a cualquier otra persona:

CATEGORIAS

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;

Productos

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

Después de truncar las tablas de categorías, puede obtener errores de entrada duplicados para las claves de URL, por lo que debe borrar las claves de URL de categoría de la url_rewritetabla.

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

1

Las respuestas de todos son geniales, pero me gustaría agregar que es CRÍTICO que los incrementos automáticos se restablezcan cuando estas tablas se truncan. Normalmente MySQL hace esto automáticamente, pero en dos entornos separados, tuve innumerables problemas para que esto NO se restablezca. Usé REGEX para encontrar y reemplazar las respuestas anteriores para agregar una TABLA DE ALTERACIÓN después de cada TRUNCATE. La mayoría de los síntomas / problemas anteriores se vieron hasta que restablecí los AUTO_INCREMENTS en todas las tablas truncadas.


0

Para borrar los detalles del usuario de la base de datos, puede realizar los siguientes pasos.

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;

Esto eliminará todos los usuarios e iniciará la identificación de la entidad desde 1.

Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.