Magento Bulk Purge products and classifications _php tutorials

Source: Internet
Author: User
In the development and template debugging Magento need to add some categories and products, wait until the site is officially online when it is a very troublesome thing, so I wrote a PHP, for the removal of products and classification

$path = Directory of "/var/html"//Website

Include ("mysql.class.php");

if ($_post[web]) {

$web =$_post[web];

$xml =simplexml_load_file ("/$path/$web/app/etc/local.xml"); Reading an XML file

$dbname = $xml->global->resources->default_setup->connection->dbname;

$password = $xml->global->resources->default_setup->connection->password;

$username = $xml->global->resources->default_setup->connection->username;

echo "dbname: $dbname". "
";

echo "Password: $password". "
";

$mysqli =new mysqli ("localhost", "$username", "$password", "$dbname");

The following is a clear statement

$csql 1= "TRUNCATE TABLE ' catalog_category_entity '";

$csql 2= "TRUNCATE TABLE ' catalog_category_entity_datetime '";

$csql 3= "TRUNCATE TABLE ' catalog_category_entity_decimal '";

$csql 4= "TRUNCATE TABLE ' catalog_category_entity_int '";

$csql 5= "TRUNCATE TABLE ' Catalog_category_entity_text '";

$csql 6= "TRUNCATE TABLE ' Catalog_category_entity_varchar '";

$csql 7= "TRUNCATE TABLE ' catalog_category_product '";

$csql 8= "TRUNCATE TABLE ' Catalog_category_product_index '";

$csql 9= "INSERT into ' catalog_category_entity ' (' entity_id ', ' entity_type_id ', ' attribute_set_id ', ' parent_id ', ' Created_at ', ' updated_at ', ' path ', ' POSITION ', ' Level ', ' Children_count ') VALUES (1,3,0,0, ' 0000-00-00 00:00:00 ', ' 2009-02-20 00:25:34 ', ' 1 ', 1,0,1), (2,3,3,0, ' 2009-02-20 00:25:34 ', ' 2009-02-20 00:25:34 ', ' 1/2 ', 1,1,0) ";

$csql 10= "INSERT into ' catalog_category_entity_int ' (' value_id ', ' entity_type_id ', ' attribute_id ', ' store_id ', ' entity _id ', ' value ') VALUES (1,3,32,0,2,1), (2,3,32,1,2,1) ";

$csql 11= "INSERT into ' Catalog_category_entity_varchar ' (' value_id ', ' entity_type_id ', ' attribute_id ', ' store_id ', ' entity_id ', ' value ') VALUES (1,3,31,0,1, ' Root Catalog '), (2,3,33,0,1, ' Root-catalog '), (3,3,31,0,2, ' Default Category ') , (4,3,39,0,2, ' products '), (5,3,33,0,2, ' default-category ') ";

$sqls = "$csql 1; $csql 2; $csql 3; $csql 4; $csql 5; $csql 6; $csql 7; $csql 8; $csql 9; $csql; $csql 11";

$dsql = "TRUNCATE TABLE ' catalog_product_bundle_option ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_bundle_option_value ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_bundle_selection ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_datetime ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_decimal ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_gallery ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_int ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_media_gallery ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_media_gallery_value ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_text ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity_tier_price ';";

$dsql. = "TRUNCATE TABLE ' Catalog_product_entity_varchar ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_link ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_link_attribute ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_link_attribute_decimal ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_link_attribute_int ';";

$dsql. = "TRUNCATE TABLE ' Catalog_product_link_attribute_varchar ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_link_type ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_option ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_option_price ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_option_title ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_option_type_price ';";

$dsql. = "TRUNCATE TABLE ' Catalog_product_option_type_title '";

$dsql. = "TRUNCATE TABLE ' catalog_product_option_type_value ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_super_attribute ';";

$dsql. = "TRUNCATE TABLE ' Catalog_product_super_attribute_label ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_super_attribute_pricing ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_super_link ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_enabled_index ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_website ';";

$dsql. = "TRUNCATE TABLE ' catalog_product_entity ';";

$dsql. = "TRUNCATE TABLE ' cataloginventory_stock ';";

$dsql. = "TRUNCATE TABLE ' Cataloginventory_stock_item ';";

$dsql. = "TRUNCATE TABLE ' cataloginventory_stock_status ';";

$dsql. = "INSERT into ' catalog_product_link_type ' (' link_type_id ', ' Code ') VALUES (1, ' Relation '), (2, ' bundle '), (3, ' Super '), (4, ' Up_sell '), (5, ' Cross_sell '); ";

$dsql. = "INSERT into ' catalog_product_link_attribute ' (' product_link_attribute_id ', ' link_type_id ', ' product_link_ Attribute_code ', ' data_type ') VALUES (, ' 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 '); ";

$dsql. = "INSERT into ' cataloginventory_stock ' (' stock_id ', ' Stock_name ') VALUES (1, ' Default ')";

echo $sqls. "
";

echo $dsql. "
";

$sql = "$dsql; $sqls";

if ($mysqli->multi_query ($sql)) {

echo "Checkproduct OK". $mysqli->insert_id. "
";

echo "Affected_rows". $mysqli->affected_rows. "
";

}

else{

echo "Checkproduct false";

}

$mysqli->close ();

}

?>

This article is from the "Mcshell Learning Blog" blog

http://www.bkjia.com/PHPjc/478727.html www.bkjia.com true http://www.bkjia.com/PHPjc/478727.html techarticle in the development of Magento and template debugging when all need to add some classification and products, wait until the site is officially online when it is a very troublesome thing, so I wrote a PHP, used to clear ...

  • 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.