Magento 2: Müşterileri, ürünleri, yorumları ve sipariş tablosunu nasıl kısaltabilirim?


34

Magento 2'deki tüm test müşterilerini, ürünlerini, incelemelerini ve siparişlerini silmek için kesmem gereken tabloların listesi var mı? Testten sonra Clearing Magento'ya benzer bir şey arıyorum .


Bu sipariş silmeye yardımcı olmalı magecomp.com/magento-2-delete-orders.html
Gaurav Jain

@ amitshree'nin yanıtındaki tüm sorguları kullandım. Fakat bazı tabloların hala birçok veriye sahip olduğunu gördüm: + ----------------------------------------- -------------------- + -------- + | Tablo | Satırlar | + ------------------------------------------------- ---------- + -------- + | 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

Yeni bir sorunuz varsa, lütfen Soru Sor düğmesine tıklayarak sorun . Bağlam sağlamaya yardımcı oluyorsa, bu soruya bir bağlantı ekleyin. - Şu kaynaktan
Rama Chandran M

Yanıtlar:


72

[Not] : Lütfen bu sorguları çalıştırmadan önce veritabanı yedeklemesini alın.

Tüm tabloları inceledim ve test verilerini temizlemek için kesilmesi gereken aşağıdaki tabloların listesini gördüm:

SET FOREIGN_KEY_CHECKS = 0;

Kesilmiş sipariş tabloları

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

Müşteri tablolarını kısalt

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

Kesintisiz Gözden Geçirme tabloları

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

Ürün Tablolarını Kes

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
Masalar bu şekilde kesilmesi sonra bir olsun 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` YABANCI KEY ( stock_id) Referanslar cataloginventory_stock( stock_idSİL CASC AÇIK)) ürünün kaydet / eklemeye çalışırken `hatası. İşe yarıyor mu?
Tom,

1
@ Tom da bu hatayı gördüm. Eğer cataloginventory_stocktabloyu kesmiyorsanız , iyi çalışacaktır.
amitshree

Bunu deneme. çünkü bu sorguyu yürüttükten sonra gruplandırılmış ürün oluşturulmayacak.
saravanavelu

@saravanavelu: neden öyle? Tablo neden sorunu yaratacak?
amitshree

Var olmayan 'konum' sütununa göre sıralamaya çalışır. Bu sorguyu yürüttükten sonra gruplandırılmış ürün oluşturmayı denediniz mi?
saravanavelu

5

TRUNCATE MÜŞTERİLERİ

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

Tüm incelemelerin silinmesi:

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

Tüm müşterilerin temizlenmesi:

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;

Tüm ürünlerin temizlenmesi:

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

Tüm siparişlerin, gönderilerin, işlemlerin vs. silinmesi:

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;

Sipariş artış kimliğini kaldırmıyor.
chirag

3

TRUNCATE KATEGORİLERİ VE KÖK KATEGORİSİ OLUŞTURMA

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

Catalog_category_entity` (`entity_id`,` attribute_set_id`, `parent_id`,` create_at`, `updated_at`,` path`, `position`," level ", children_count`) INSERT DEĞERLERI ('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 ');
Catalog_category_entity_datetime `(` value_id`, `attribute_id`,` store_id`, `entity_id`,` value`) INSERT DEĞERLERI ('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`) DEĞERLER
(1, 69, 0, 2, NULL);
Catalog_category_entity_int` (`value_id`,` attribute_id`, `store_id`,` entity_id`, `value`) INSERT DEĞERLER ('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`) DEĞERLER ('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`) DEĞERLER ('1', '42', '0', '1', 'Kök Katalog');
Catalog_category_entity_varchar` (`value_id`,` attribute_id`, `store_id`,` entity_id`, `value`) INSERT DEĞERLERI (2, 42, 0, 2, 'Varsayılan Kategori'), (3, 46, 0, 2 , NULL), (4, 49, 0, 2, 'ÜRÜNLER'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2 , NULL), (8, 113, 0, 2, 'varsayılan kategori'), (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 KATEGORİLERİ

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_attributeTabloyu kesmeyin , aksi takdirde gruplandırılmış ürünler oluştururken bir sorunla karşılaşırsınız. Bunun dışında, @amitshree https://magento.stackexchange.com/a/102995/14787 tarafından belirtilen diğer tabloları kesebilirsiniz.

Bu tabloyu zaten kesmişseniz, aşağıdaki gibi kayıtları ekleyin: -

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

Bu doğru olanı

DELETE FROM catalog_product_entity;

Kesme işlevini kullanmak daha iyidir çünkü otomatik artış değerini de sıfırlar, böylece yeni öğelerinizin kimlikleri tekrar 1'den başlar.
Ziki

Tamam @ Ziki
Gowthaman

2

Burada Magento 2.2.6, bir bin / magento sampledata sonra veritabanını temizlemek zorunda kaldı: kaldır.

Kısa öykü uzun, siparişler , müşteriler ve incelemeler için yukarıda SQL hala çalışıyor (eklemeyi unutmayın ALTER TABLE xxx AUTO_INCREMENT=1;) ama kategoriler ve ürünler için bazı şeyler tweak zorunda kaldı .

Bu yeni özetin başkalarına yardımcı olabileceğine inanıyorum:

KATEGORİLER

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;

ÜRÜNLER

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

Kategori tablolarını kısaltdıktan sonra, URL tuşları için yinelenen giriş hataları alabilirsiniz; böylece kategori URL anahtarlarını url_rewritetablodan silmeniz gerekir .

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

1

Herkesin cevapları harika, ancak bu tablolar kesildiğinde Otomatik Artışların sıfırlanmasının KRİTİK olduğunu eklemek isterim. Normalde MySQL bunu otomatik olarak yapar, ancak iki ayrı ortamda, bu sıfırlama konusunda sayısız sorun yaşadım. Her TRUNCATE tarihinden sonra bir ALTER TABLE eklemek için yukarıdaki cevapları bulup değiştirmek için REGEX kullandım. Yukarıdaki semptomların / sorunların çoğu, tüm kesilmiş masalarda AUTO_INCREMENTS öğesini sıfırlayana kadar görüldü.


0

Kullanıcı detaylarını veri tabanından silmek için aşağıdaki adımları uygulayabilirsiniz.

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;

Bu, tüm kullanıcıları kaldıracak ve varlık kimliğini 1'den başlatacaktır.

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.