Home Backend Development PHP Tutorial Magento batch clear products and categories_PHP tutorial

Magento batch clear products and categories_PHP tutorial

Jul 13, 2016 pm 05:44 PM
magento product point Classification join in and exist develop batch template Clear of debug need

When developing magento and debugging templates, you need to add some categories and products. It will be very troublesome when the website is officially launched, so I wrote a php myself to clear products and categories

 

Enter check product web:

 

 

 

 

 

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

 

                      $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 (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,用于清除...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use LeakSanitizer to debug C++ memory leaks? How to use LeakSanitizer to debug C++ memory leaks? Jun 02, 2024 pm 09:46 PM

How to use LeakSanitizer to debug C++ memory leaks? Install LeakSanitizer. Enable LeakSanitizer via compile flag. Run the application and analyze the LeakSanitizer report. Identify memory allocation types and allocation locations. Fix memory leaks and ensure all dynamically allocated memory is released.

Shortcut to golang function debugging and analysis Shortcut to golang function debugging and analysis May 06, 2024 pm 10:42 PM

This article introduces shortcuts for Go function debugging and analysis, including: built-in debugger dlv, which is used to pause execution, check variables, and set breakpoints. Logging, use the log package to record messages and view them during debugging. The performance analysis tool pprof generates call graphs and analyzes performance, and uses gotoolpprof to analyze data. Practical case: Analyze memory leaks through pprof and generate a call graph to display the functions that cause leaks.

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

PHP Debugging Errors: A Guide to Common Mistakes PHP Debugging Errors: A Guide to Common Mistakes Jun 05, 2024 pm 03:18 PM

Common PHP debugging errors include: Syntax errors: Check the code syntax to make sure there are no errors. Undefined variable: Before using a variable, make sure it is initialized and assigned a value. Missing semicolons: Add semicolons to all code blocks. Function is undefined: Check that the function name is spelled correctly and make sure the correct file or PHP extension is loaded.

How to debug PHP asynchronous code How to debug PHP asynchronous code May 31, 2024 am 09:08 AM

Tools for debugging PHP asynchronous code include: Psalm: a static analysis tool that can find potential errors. ParallelLint: A tool that inspects asynchronous code and provides recommendations. Xdebug: An extension for debugging PHP applications by enabling a session and stepping through the code. Other tips include using logging, assertions, running code locally, and writing unit tests.

Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Aug 10, 2024 pm 10:15 PM

Using light to train neural networks, Tsinghua University results were recently published in Nature! What should I do if I cannot apply the backpropagation algorithm? They proposed a Fully Forward Mode (FFM) training method that directly performs the training process in the physical optical system, overcoming the limitations of traditional digital computer simulations. To put it simply, it used to be necessary to model the physical system in detail and then simulate these models on a computer to train the network. The FFM method eliminates the modeling process and allows the system to directly use experimental data for learning and optimization. This also means that training no longer needs to check each layer from back to front (backpropagation), but can directly update the parameters of the network from front to back. To use an analogy, like a puzzle, backpropagation

How do new features of PHP functions simplify the development process? How do new features of PHP functions simplify the development process? May 04, 2024 pm 09:45 PM

The new features of PHP functions greatly simplify the development process, including: Arrow function: Provides concise anonymous function syntax to reduce code redundancy. Property type declaration: Specify types for class properties, enhance code readability and reliability, and automatically perform type checking at runtime. null operator: concisely checks and handles null values, can be used to handle optional parameters.

What are the debugging techniques for recursive calls in Java functions? What are the debugging techniques for recursive calls in Java functions? May 05, 2024 am 10:48 AM

The following techniques are available for debugging recursive functions: Check the stack traceSet debug pointsCheck if the base case is implemented correctlyCount the number of recursive callsVisualize the recursive stack

See all articles