magento批量清除产品和分类

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:
在magento的开发和模板调试的时候都需要加入一些分类和产品,等到网站正式上线的时候又是很麻烦的事情,所以自己写了一个php,用于清除产品和分类
< form  action ="" method="post" > 
    
Enter check product web: 
    
     < input  type ="text"  name ="web"     size ="40"  maxlength ="40" /> 
    
     < input  type ="submit"  name ="sub"  value ="submit" > 
    
     </form> 
    
<?php 
    
$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"." < br >"; 
    
                echo "password:$password"." < br >"; 
    
$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." < br >"; 
    
echo $dsql." < br >"; 
    
$sql="$dsql;$sqls"; 
    
if($mysqli->multi_query($sql)){ 
    
                echo "CheckProduct Ok".$mysqli->insert_id." < br >"; 
    
                echo "affected_rows".$mysqli->affected_rows." < br >"; 
    

    
else{ 
    
                echo"CheckProduct false"; 
    

    
$mysqli->close(); 
    

    
?>









本文转自 mcshell 51CTO博客,原文链接:http://blog.51cto.com/mcshell/624404,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
2月前
Dataphin功能Tips系列(5)-手工表上传及长期维护
有些业务数据是手工excel维护的,这时我们要如何将数据上传至dataphin并进行维护?
|
9月前
|
SQL Java 关系型数据库
从系统报表页面导出20w条数据到本地只用了4秒,我是如何做到的
最近有个学弟找到我,跟我描述了以下场景: 他们公司内部管理系统上有很多报表,报表数据都有分页显示,浏览的时候速度还可以。但是每个报表在导出时间窗口稍微大一点的数据时,就异常缓慢,有时候多人一起导出时还会出现堆溢出。 他知道是因为数据全部加载到jvm内存导致的堆溢出。所以只能对时间窗口做了限制。以避免因导出过数据过大而引起的堆溢出。最终拍脑袋定下个限制为:导出的数据时间窗口不能超过1个月。
|
12月前
|
Web App开发 人工智能 算法
为什么GNE 不做全自动提取列表页的功能
为什么GNE 不做全自动提取列表页的功能
79 0
|
Web App开发 安全 Windows
win10_x64更新错误解决: 安装一些更新时出现问题,但我们稍后会重试。如果持续出现这些问题,并且你想要搜索Web或联系支持人员以获取相关信息,以下信息可能会对你有帮助:
可能的原因:  1、windows 服务没打开 win+r,打开【运行】对话框 输入 【service.msc】 找到 【Windows Firewall】和【Internet connection sharing】 都启动,并设为【自动】,重新启动 【设置】--【更新和安全】 2、设置的代理,但是代理没打开 将设置的代理服务器打开。
6356 0
|
Oracle 关系型数据库 Shell
[自制工具]批量后台更新统计信息
Oracle数据库有时需要批量收集数据库的统计信息,如在大量数据迁移或大量数据更新以后,但是收集的时间可能会较长,为了避免网络中断等意外情况可能引起的麻烦,今天调试了这个小脚本,可以分用户批量执行,同时记录执行时间等日志信息,比较实用。
176 0
|
搜索推荐 SEO
网站内容更新频率如何控制?网站内容更新注意事项
网站更新是每个站长必做的功课,当一个网站创建完成后,开始更新网站内容。 更新内容并不是说一个月时间内,把挖掘出来的内容、关键词全部一次性用上,这样的做法是错误的,搜索引擎是非常反感的。正确的做法是循序渐进的更新网站,不是像一台机器在采集,举个例子:个人博客今天发送3篇文稿,明天也3篇,后天还是一样3篇,天天坚持持续一段时间,是被搜索引擎认可的。
167 0