> 백엔드 개발 > PHP 튜토리얼 > magento批量清除产品和分类_PHP教程

magento批量清除产品和分类_PHP教程

WBOY
풀어 주다: 2016-07-13 17:44:42
원래의
930명이 탐색했습니다.

 

在magento的开发和模板调试的时候都需要加入一些分类和产品,等到网站正式上线的时候又是很麻烦的事情,所以自己写了一个php,用于清除产品和分类

   

Enter check product web:

   

   

   

   

   

   

   

   

$path="/var/html"        //网站的目录

   

//include("mysql.class.php");

   

if($_POST[web]){

   

                $web=$_POST[web];

   

                $xml=simplexml_load_file("/$path/$web/app/etc/local.xml");     //读取xml文件

   

                $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");

   

//以下是清除语句

   

$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 (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)";

   

$csql10="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)";

   

$csql11="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="$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_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 (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');";

   

$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();

   

}

   

?>

本文出自 “mcshell学习博客” 博客

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478727.htmlTechArticle在magento的开发和模板调试的时候都需要加入一些分类和产品,等到网站正式上线的时候又是很麻烦的事情,所以自己写了一个php,用于清除...
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿