您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/4/28 16:29:02发布15次查看
在magento的开发和模板调试的时候都需要加入一些分类和产品,等到网站正式上线的时候又是很麻烦的事情,所以自己写了一个php,用于清除产品和分类
enter check product web:
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{
echocheckproduct false;
}
$mysqli->close();
}
?>
本文出自 “mcshell学习博客” 博客
http://www.bkjia.com/phpjc/478727.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/478727.htmltecharticle在magento的开发和模板调试的时候都需要加入一些分类和产品,等到网站正式上线的时候又是很麻烦的事情,所以自己写了一个php,用于清除...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product