Some categories and products need to be added during magento development and template debugging. it is very troublesome when the website is officially launched, so I wrote a php file myself, used to clear products and categories & lt; formaction & quot; method & quot; post & quot; & gt; Entercheckproductweb :...
Some categories and products need to be added during magento development and template debugging. it is very troublesome when the website is officially launched, so I wrote a php file myself, used to clear products and categories
$ Path = "/var/html" // Website Directory
// Include ("mysql. class. php ");
If ($ _ POST [web]) {
$ Web =$ _ POST [web];
$ Xml = simplexml_load_file ("/$ path/$ web/app/etc/local. xml"); // read xml files
$ 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 the clear statement.
$ Csql1 = "truncate table 'catalog _ category_entity '";
$ Csql2 = "truncate table 'catalog _ category_entity_datetime '";
$ Csql3 = "truncate table 'catalog _ category_entity_decimal '";
$ Csql4 = "truncate table 'catalog _ category_entity_int '";
$ Csql5 = "truncate table 'catalog _ category_entity_text '";
$ Csql6 = "truncate table 'catalog _ category_entity_varchar '";
$ Csql7 = "truncate table 'catalog _ category_product '";
$ Csql8 = "truncate table 'catalog _ category_product_index '";
$ Csql9 = "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, '2014-00-00 00:00:00 ', '2014-02-20 00:25:34', '1', 0000, 1), (2009, '2017-02-20 00:25:34 ', '2017-02-20 00:25:34', '2017 ', 2009, 0 )";
$ Csql10 = "insert into 'catalog _ category_entity_int '('value _ id', 'entity _ type_id', 'attribute _ id', 'Store _ id ', 'entity _ id', 'value') VALUES )";
$ Csql11 = "insert into '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 ')";
$ Sqls = "$ csql1; $ csql2; $ csql3; $ csql4; $ csql5; $ csql6; $ csql7; $ csql8; $ csql9; $ csql10; $ csql11 ";
$ 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 _ failed'), (5, 'cross _ failed ');";
$ Dsql. = "insert into 'catalog _ product_link_attribute '('product _ link_attribute_id', 'link _ type_id ', 'product _ link_attribute_code', 'data _ type') VALUES (1, 2, 'qty ', 'decimal'), (, 'position', 'int'), (, 'position', 'int'), (, 'position ', 'int'), (6, 1, 'qty ', 'decimal'), (, 'position', 'int'), (, '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