How to batch Delete products in the magento background

Source: Internet
Author: User
How to batch Delete products in magento background

How does magento batch Delete products? Anyone who has used magento knows that it is very slow to delete products in batches in the magento background. 30 products cannot be deleted in one minute. Select
A time get out 504 error may occur when multiple products Perform Batch deletion.
. This is because each product has many attributes and is associated with nearly 30 tables in the database. Each time a product is deleted, the database must query more than 30 tables, therefore, the more products that are deleted in batches, the more expensive
The longer the time, the more likely the server will time out.
The following describes a simple method to delete nearly a thousand products within 3 seconds (it is best to back up the database before doing so, I tested it in magento1.4): First open your magento database, select SQL and copy the following code to run the SQL query in the database magento:

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 ';
Truncate table 'catalog _ product_super_attribute_label ';
Truncate table 'catalog _ product_super_attribute_pricing ';
Truncate table 'catalog _ product_super_link ';
Truncate table 'catalog _ product_enabled_index ';
Truncate table 'catalog _ product_website ';
Truncate table 'catalog _ product_entity ';
Truncate table 'cataloginventory _ stock ';
Truncate table 'cataloginventory _ stock_item ';
Truncate table 'cataloginventory _ stock_status ';
Insert
Into 'catalog _ product_link_type '('link _ type_id', 'code') Values
(1, 'relation'), (2, 'bundle'), (3, 'super'), (4, 'Up _ login'), (5, 'Cross _ Region ');
Insert
Into
'Catalog _ product_link_attribute '('product _ link_attribute_id', 'link _ type_id ', 'product _ link_attribute_code', 'Data _ type ')
Values
(, 'Qty ', 'decimal'), (, 'position', 'int'), (, 'position', 'int, 'position', 'int'), (6, 1, 'qty ', 'decimal'), (, 'position', 'int'), (, 'qty ', 'decimal ');

Insert into 'cataloginventory _ stock' ('Stock _ id', 'stock _ name') values (1, 'default ');

Soon, the records of all products and products were deleted in just a few seconds, saving a lot of valuable time.
In addition, this article describes how to delete a product category directory through a database:
Copy the following code to run the SQL query in the database magento.
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 '; <H2> </H2> Truncate table 'catalog _ category_product_index ';
Insert
Into
'Catalog _ category_entit' ('entity _ id', 'entity _ type_id ', 'attribute _ set_id', 'parent _ id', 'created _ ', 'updated _ at', 'path', 'position', 'level', 'Children _ count ')
Values (0000, 2009, '2017-00-00 00:00:00 ', '2017-02-20
00:25:34 ', '1', 2009, 1), (2009,-02-20 00:25:34', '2017-02-20
00:25:34 ', '123', 1/2, 0 );
Insert
'Catalog _ category_entity_int '('value _ id', 'entity _ type_id', 'attribute _ id', 'store _ id', 'entity _ id', 'value ')
Values );
Insert
'Catalog _ category_entity_varchar '('value _ id', 'entity _ type_id', 'attribute _ id', 'store _ id', 'entity _ id', 'value ')
Values (, 1, 'root
Catalog '), (, 1, 'root-catalog'), (, 2, 'default
CATEGORY '), (, 2, 'products'), (, 2, 'default-category ');

In this way, the directory and related information are quickly deleted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.