id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	modified_flg
236	CSVからカテゴリを登録できるようにしました。	miningbrownie	miningbrownie	"http://webml.ec-cube.net/comu-ml/200802/msg00000.html

大量のカテゴリを作成するときに楽なようにCSVからの登録を出来るようにしました。

「商品管理」に「カテゴリーCSV」のメニューが出来ます。

== 仕様 ==
CSVの項目は

1項目：カテゴリID

2項目：カテゴリ名(※ 必須)

3項目：親カテゴリID

4項目：階層

5項目：表示順

となっております。

=== カテゴリID ===
未入力の場合現在あるカテゴリIDの最大値+1がカテゴリIDになります。
=== 親カテゴリID ===
未入力の場合、0となります。
存在しない場合はエラーとなります。
=== 階層 ===
未入力かつ親カテゴリIDも未入力の場合、1になります。
未入力で親カテゴリがある場合、親カテゴリの階層+1になります。
=== 表示順 ===
未入力の場合、同じ親カテゴリIDの中で一番大きな値がつきます。


== パッチ ==
{{{
diff -urN eccube-2.0.1.org/data/Smarty/templates/default/admin/products/subnavi.tpl eccube-2.0.1/data/Smarty/templates/default/admin/products/subnavi.tpl
--- eccube-2.0.1.org/data/Smarty/templates/default/admin/products/subnavi.tpl	2007-10-29 12:06:29.000000000 +0900
+++ eccube-2.0.1/data/Smarty/templates/default/admin/products/subnavi.tpl	2008-02-02 08:31:58.000000000 +0900
@@ -33,7 +33,9 @@
 	<tr><td><img src=""<!--{$TPL_DIR}-->img/contents/navi_line.gif"" width=""140"" height=""2"" alt=""""></td></tr>
 	<tr><td class=<!--{if $tpl_subno != 'category'}-->""navi""<!--{else}-->""navi-on""<!--{/if}-->><a href=""./category.php"" onMouseOver=""naviStyleChange('category', '#a5a5a5')"" <!--{if $tpl_subno != 'category'}-->onMouseOut=""naviStyleChange('category', '#636469')""<!--{/if}--> id=""category""><img src=""<!--{$TPL_DIR}-->img/contents/icon.jpg"" width=""15"" height=""9"" alt="""" border=""0""><span class=""navi_text"">カテゴリー管理</span></a></td></tr>
 	<tr><td><img src=""<!--{$TPL_DIR}-->img/contents/navi_line.gif"" width=""140"" height=""2"" alt=""""></td></tr>
-	<tr><td class=<!--{if $tpl_subno != 'product_rank'}-->""navi""<!--{else}-->""navi-on""<!--{/if}-->><a href=""./product_rank.php"" onMouseOver=""naviStyleChange('product_rank', '#a5a5a5')"" <!--{if $tpl_subno != 'product_rank'}-->onMouseOut=""naviStyleChange('product_rank', '#636469')""<!--{/if}--> id=""product_rank""><img src=""<!--{$TPL_DIR}-->img/contents/icon.jpg"" width=""15"" height=""9"" alt="""" border=""0""><span class=""navi_text"">商品並び替え</span></a></td></tr>
+	<tr><td class=<!--{if $tpl_subno != 'upload_csv_category'}-->""navi""<!--{else}-->""navi-on""<!--{/if}-->><a href=""./upload_csv_category.php"" onMouseOver=""naviStyleChange('upload_csv_category', '#a5a5a5')"" <!--{if $tpl_subno != 'upload_csv_category'}-->onMouseOut=""naviStyleChange('upload_csv_category', '#636469')""<!--{/if}--> id=""upload_csv_category""><img src=""<!--{$TPL_DIR}-->img/contents/icon.jpg"" width=""15"" height=""9"" alt="""" border=""0""><span class=""navi_text"">カテゴリーCSV</span></a></td></tr>
+    <tr><td><img src=""<!--{$TPL_DIR}-->img/contents/navi_line.gif"" width=""140"" height=""2"" alt=""""></td></tr>
+    <tr><td class=<!--{if $tpl_subno != 'product_rank'}-->""navi""<!--{else}-->""navi-on""<!--{/if}-->><a href=""./product_rank.php"" onMouseOver=""naviStyleChange('product_rank', '#a5a5a5')"" <!--{if $tpl_subno != 'product_rank'}-->onMouseOut=""naviStyleChange('product_rank', '#636469')""<!--{/if}--> id=""product_rank""><img src=""<!--{$TPL_DIR}-->img/contents/icon.jpg"" width=""15"" height=""9"" alt="""" border=""0""><span class=""navi_text"">商品並び替え</span></a></td></tr>
 	<tr><td><img src=""<!--{$TPL_DIR}-->img/contents/navi_line.gif"" width=""140"" height=""2"" alt=""""></td></tr>
 	<tr><td class=<!--{if $tpl_subno != 'review'}-->""navi""<!--{else}-->""navi-on""<!--{/if}-->><a href=""./review.php"" onMouseOver=""naviStyleChange('review', '#a5a5a5')"" <!--{if $tpl_subno != 'review'}-->onMouseOut=""naviStyleChange('review', '#636469')""<!--{/if}--> id=""review""><img src=""<!--{$TPL_DIR}-->img/contents/icon.jpg"" width=""15"" height=""9"" alt="""" border=""0""><span class=""navi_text"">レビュー管理</span></a></td></tr>
 	<tr><td><img src=""<!--{$TPL_DIR}-->img/contents/navi_line.gif"" width=""140"" height=""2"" alt=""""></td></tr>
diff -urN eccube-2.0.1.org/data/Smarty/templates/default/admin/products/upload_csv_category.tpl eccube-2.0.1/data/Smarty/templates/default/admin/products/upload_csv_category.tpl
--- eccube-2.0.1.org/data/Smarty/templates/default/admin/products/upload_csv_category.tpl	1970-01-01 09:00:00.000000000 +0900
+++ eccube-2.0.1/data/Smarty/templates/default/admin/products/upload_csv_category.tpl	2008-02-02 08:31:58.000000000 +0900
@@ -0,0 +1,135 @@
+<!--{*
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+*}-->
+<!--★★メインコンテンツ★★-->
+<form name=""form1"" id=""form1"" method=""post"" action=""<!--{$smarty.server.PHP_SELF|escape}-->"" enctype=""multipart/form-data"" onSubmit=""winSubmit('','form1', 'upload', 500, 400)"">
+<input type=""hidden"" name=""mode"" value=""csv_upload"">
+<table width=""878"" border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+	<tr valign=""top"">
+		<td background=""<!--{$TPL_DIR}-->img/contents/navi_bg.gif"" height=""402"">
+			<!-- サブナビ -->
+			<!--{include file=$tpl_subnavi}-->
+		</td>
+		<td class=""mainbg"">
+		<table width=""737"" border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+			<!--メインエリア-->
+			<tr>
+				<td align=""center"">
+				<table width=""706"" border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+					<tr><td height=""14""></td></tr>
+					<tr>
+						<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/main_top.jpg"" width=""706"" height=""14"" alt=""""></td>
+					</tr>
+					<tr>
+						<td background=""<!--{$TPL_DIR}-->img/contents/main_left.jpg""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""14"" height=""1"" alt=""""></td>
+						<td bgcolor=""#cccccc"">
+						<table width=""678"" border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+							<tr>
+								<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/contents_title_top.gif"" width=""678"" height=""7"" alt=""""></td>
+							</tr>
+							<tr>
+								<td background=""<!--{$TPL_DIR}-->img/contents/contents_title_left_bg.gif""><img src=""<!--{$TPL_DIR}-->img/contents/contents_title_left.gif"" width=""22"" height=""12"" alt=""""></td>
+								<td bgcolor=""#636469"" width=""638"" class=""fs14n""><span class=""white""><!--コンテンツタイトル-->カテゴリ登録CSV</span></td>
+								<td background=""<!--{$TPL_DIR}-->img/contents/contents_title_right_bg.gif""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""18"" height=""1"" alt=""""></td>
+							</tr>
+							<tr>
+								<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/contents_title_bottom.gif"" width=""678"" height=""7"" alt=""""></td>
+							</tr>
+							<tr>
+								<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/main_bar.jpg"" width=""678"" height=""10"" alt=""""></td>
+							</tr>
+						</table>
+
+						<!--{if $tpl_errtitle != """"}-->
+						<table width=""678"" border=""0"" cellspacing=""1"" cellpadding=""5"" summary="" "" bgcolor=""#cccccc"">
+						<tr><td bgcolor=""#ffffff"">
+							<span class=""red12""><!--{$tpl_errtitle}--><br><br></span>
+							<!--{foreach key=key item=item from=$arrCSVErr}-->
+							<span class=""red12""><!--{$item}-->
+							<!--{if $key != 'blank'}-->
+							[値：<!--{$arrParam[$key]}-->]
+							<!--{/if}-->
+							<br></span>
+							<!--{/foreach}-->
+						</td></tr>
+						</table>
+						<!--{/if}-->
+
+						<!--▼登録テーブルここから-->
+						<table width=""678"" border=""0"" cellspacing=""1"" cellpadding=""5"" summary="" "" bgcolor=""#cccccc"">
+							<tr class=""fs12n"">
+								<td bgcolor=""#f0f0f0"" width=""110"">CSVファイル</td>
+								<td bgcolor=""#ffffff"" width=""607"">
+								<span class=""red12""><!--{$arrErr.csv_file}--></span>
+								<input type=""file"" name=""csv_file"" size=""60"" class=""box60"" /><span class=""red10""> (1行目タイトル行)</span></td>
+							</tr>
+							<tr class=""fs12n"">
+								<td bgcolor=""#f0f0f0"" width=""110"">登録情報</td>
+								<td bgcolor=""#ffffff"" width=""607"">
+								<!--{foreach name=title key=key item=item from=$arrTitle}-->
+								<!--{$smarty.foreach.title.iteration}-->項目：<!--{$item}--><br>
+								<!--{/foreach}-->
+								</td>
+							</tr>
+						</table>
+						<!--▲登録テーブルここまで-->
+						<table width=""678"" border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+							<tr>
+								<td bgcolor=""#cccccc""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""1"" height=""5"" alt=""""></td>
+								<td><img src=""<!--{$TPL_DIR}-->img/contents/tbl_top.gif"" width=""676"" height=""7"" alt=""""></td>
+								<td bgcolor=""#cccccc""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""1"" height=""5"" alt=""""></td>
+							</tr>
+							<tr>
+								<td bgcolor=""#cccccc""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""1"" height=""10"" alt=""""></td>
+								<td bgcolor=""#e9e7de"" align=""center"">
+								<table border=""0"" cellspacing=""0"" cellpadding=""0"" summary="" "">
+									<tr>
+									<td>
+										<input type=""image"" onMouseover=""chgImgImageSubmit('<!--{$TPL_DIR}-->img/contents/btn_regist_on.jpg',this)"" onMouseout=""chgImgImageSubmit('<!--{$TPL_DIR}-->img/contents/btn_regist.jpg',this)"" src=""<!--{$TPL_DIR}-->img/contents/btn_regist.jpg"" width=""123"" height=""24"" alt=""この内容で登録する"" border=""0"" name=""subm"" >
+									</td>
+									</tr>
+								</table>
+								</td>
+								<td bgcolor=""#cccccc""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""1"" height=""10"" alt=""""></td>
+							</tr>
+							<tr>
+								<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/tbl_bottom.gif"" width=""678"" height=""8"" alt=""""></td>
+							</tr>
+						</table>										
+						</td>
+						<td background=""<!--{$TPL_DIR}-->img/contents/main_right.jpg""><img src=""<!--{$TPL_DIR}-->img/common/_.gif"" width=""14"" height=""1"" alt=""""></td>
+					</tr>					
+					<tr>
+						<td colspan=""3""><img src=""<!--{$TPL_DIR}-->img/contents/main_bottom.jpg"" width=""706"" height=""14"" alt=""""></td>
+					</tr>
+					<tr><td height=""30""></td></tr>
+				</table>
+				</td>
+			</tr>
+			<!--メインエリア-->
+		</table>
+		</td>
+	</tr>
+</form>	
+</table>
+<!--▲CONTENTS-->
\ ファイル末尾に改行がありません
diff -urN eccube-2.0.1.org/data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php eccube-2.0.1/data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php
--- eccube-2.0.1.org/data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php	1970-01-01 09:00:00.000000000 +0900
+++ eccube-2.0.1/data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php	2008-02-02 08:31:58.000000000 +0900
@@ -0,0 +1,363 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . ""pages/admin/products/LC_Page_Admin_Products_UploadCSV.php"");
+
+/**
+ * CSV アップロード のページクラス(拡張)
+ *
+ * LC_Page_Admin_Products_UploadCSV をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $$Id: LC_Page_Admin_Products_UploadCSV_Ex.php 16741 2007-11-08 00:43:24Z adachi $$
+ */
+class LC_Page_Admin_Products_UploadCSVCategory_Ex extends LC_Page_Admin_Products_UploadCSV {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = 'products/upload_csv_category.tpl';
+        $this->tpl_subnavi = 'products/subnavi.tpl';
+        $this->tpl_mainno = 'products';
+        $this->tpl_subno = 'upload_csv_category';
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $conn = new SC_DBConn();
+        $objView = new SC_AdminView();
+        $objSess = new SC_Session();
+        $objDb = new SC_Helper_DB_Ex();
+
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess($objSess);
+
+        // ファイル管理クラス
+        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
+        // ファイル情報の初期化
+        $this->lfInitFile();
+        // パラメータ管理クラス
+        $this->objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam();
+        $colmax = $this->objFormParam->getCount();
+        $this->objFormParam->setHtmlDispNameArray();
+        $this->arrTitle = $this->objFormParam->getHtmlDispNameArray();
+
+        if (!isset($_POST['mode'])) $_POST['mode'] = """";
+
+        switch($_POST['mode']) {
+            case 'csv_upload':
+                $err = false;
+                // エラーチェック
+                $arrErr['csv_file'] = $this->objUpFile->makeTempFile('csv_file');
+
+                if($arrErr['css_file'] == """") {
+                    $arrErr = $this->objUpFile->checkEXISTS();
+                }
+
+                // 実行時間を制限しない
+                set_time_limit(0);
+
+                // 出力をバッファリングしない(==日本語自動変換もしない)
+                ob_end_clean();
+
+                // IEのために256バイト空文字出力
+                echo str_pad('',256);
+
+                if(empty($arrErr['csv_file'])) {
+                    // 一時ファイル名の取得
+                    $filepath = $this->objUpFile->getTempFilePath('csv_file');
+                    // エンコード
+                    $enc_filepath = SC_Utils_Ex::sfEncodeFile($filepath,
+                    CHAR_CODE, CSV_TEMP_DIR);
+
+                    // レコード数を得る
+                    $rec_count = $this->lfCSVRecordCount($enc_filepath);
+
+                    $fp = fopen($enc_filepath, ""r"");
+                    $line = 0;      // 行数
+                    $regist = 0;    // 登録数
+
+                    $objQuery = new SC_Query();
+                    $objQuery->begin();
+
+                    echo ""■　CSV登録進捗状況 <br/><br/>\n"";
+
+                    while(!feof($fp) && !$err) {
+                        $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
+
+                        // 行カウント
+                        $line++;
+
+                        if($line <= 1) {
+                            continue;
+                        }
+
+                        // 項目数カウント
+                        $max = count($arrCSV);
+
+                        // 項目数が1以下の場合は無視する
+                        if($max <= 1) {
+                            continue;
+                        }
+
+                        // 項目数チェック
+                        if($max != $colmax) {
+                            echo ""※ 項目数が"" . $max . ""個検出されました。項目数は"" . $colmax . ""個になります。</br>\n"";
+                            $err = true;
+                        } else {
+                            // シーケンス配列を格納する。
+                            $this->objFormParam->setParam($arrCSV, true);
+                            $arrRet = $this->objFormParam->getHashArray();
+                            $this->objFormParam->setParam($arrRet);
+                            // 入力値の変換
+                            $this->objFormParam->convParam();
+                            // <br>なしでエラー取得する。
+                            $arrCSVErr = $this->lfCheckError();
+                        }
+
+                        // 入力エラーチェック
+                        if(count($arrCSVErr) > 0) {
+                            echo ""<font color=\""red\"">■"" . $line . ""行目でエラーが発生しました。</font></br>\n"";
+                            foreach($arrCSVErr as $val) {
+                                $this->printError($val);
+                            }
+                            $err = true;
+                        }
+
+                        if(!$err) {
+                            $this->lfRegistProduct($objQuery, $line);
+                            $regist++;
+                        }
+                        $arrParam = $this->objFormParam->getHashArray();
+
+                        if(!$err) echo $line."" / "".$rec_count. ""行目　（カテゴリID："".$arrParam['category_id']."" / カテゴリ名："".$arrParam['category_name']."")\n<br />"";
+                        flush();
+                    }
+                    fclose($fp);
+
+                    if(!$err) {
+                        $objQuery->commit();
+                        echo ""■"" . $regist . ""件のレコードを登録しました。"";
+                        // カテゴリ件数カウント関数の実行
+                        $objDb->sfCategory_Count($objQuery);
+                    } else {
+                        $objQuery->rollback();
+                    }
+                } else {
+                    foreach($arrErr as $val) {
+                        $this->printError($val);
+                    }
+                }
+                echo ""<br/><a href=\""javascript:window.close()\"">→閉じる</a>"";
+                flush();
+                exit;
+                break;
+            default:
+                break;
+        }
+
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+
+    /**
+     * ファイル情報の初期化を行う.
+     *
+     * @return void
+     */
+    function lfInitFile() {
+        $this->objUpFile->addFile(""CSVファイル"", 'csv_file', array('csv'),
+        CSV_SIZE, true, 0, 0, false);
+    }
+
+    /**
+     * 入力情報の初期化を行う.
+     *
+     * @return void
+     */
+    function lfInitParam() {
+        $this->objFormParam->addParam(""カテゴリID"",""category_id"",INT_LEN,""n"",array(""MAX_LENGTH_CHECK"",""NUM_CHECK""));
+        $this->objFormParam->addParam(""カテゴリ名"",""category_name"",STEXT_LEN,""KVa"",array(""EXIST_CHECK"",""SPTAB_CHECK"",""MAX_LENGTH_CHECK""));
+        $this->objFormParam->addParam(""親カテゴリID"",""parent_category_id"",INT_LEN,""n"",array(""MAX_LENGTH_CHECK"",""NUM_CHECK""));
+        $this->objFormParam->addParam(""階層"",""level"",INT_LEN,""n"",array(""MAX_LENGTH_CHECK"",""NUM_CHECK""));
+        $this->objFormParam->addParam(""表示順"",""rank"",INT_LEN,""n"",array(""MAX_LENGTH_CHECK"",""NUM_CHECK""));
+        //     $this->objFormParam->addParam(""削除フラグ"",""del_flg"",INT_LEN,""n"",array());
+    }
+
+    /**
+     * カテゴリ登録を行う.
+     *
+     * @param SC_Query $objQuery SC_Queryインスタンス
+     * @param string|integer $line 処理中の行数
+     * @return void
+     */
+    function lfRegistProduct($objQuery, $line = """") {
+        $objDb = new SC_Helper_DB_Ex();
+        $arrRet = $this->objFormParam->getHashArray();
+        foreach($arrRet as $key => $val) {
+            switch($key) {
+                case 'parent_category_id':
+
+                    break;
+                default:
+                    if(!ereg(""^dummy"", $key)) {
+                        $sqlval[$key] = $val;
+                    }
+                    break;
+            }
+        }
+        // 登録時間を生成(DBのnow()だとcommitした際、すべて同一の時間になってしまう)
+        $time = date(""Y-m-d H:i:s"");
+        // 秒以下を生成
+        if($line != """") {
+            $microtime = sprintf(""%06d"", $line);
+            $time .= "".$microtime"";
+        }
+        $sqlval['update_date'] = $time;
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+        //カテゴリIDの設定。
+        $update = false;
+        if($arrRet['category_id'] != """"){
+            $sqlval['category_id'] = $arrRet['category_id'];
+            $update = true;
+        }else{
+            $category_id = $objQuery->max(""dtb_category"",""category_id"")+1;
+            $sqlval['category_id'] = $category_id;
+            $count = $objQuery->count(""dtb_category"", ""category_id = ?"", array($arrRet['category_id']));
+            if($count == 0){
+                $update = false;
+            }else{
+                $update = true;
+            }
+        }
+
+        //親カテゴリIDの設定
+        if($arrRet['parent_category_id'] == """"){
+            $sqlval['parent_category_id'] = 0;
+            $sqlval['level'] = 1;
+        }else{
+            $sqlval['parent_category_id'] = $arrRet['parent_category_id'];
+            $parent_level = $objQuery->get('dtb_category','level',""category_id = ?"",array($sqlval['parent_category_id']));
+            $sqlval['level'] = $parent_level+1;
+        }
+        
+
+        if($update) {
+            // UPDATEの実行
+            echo ""UPDATEの実行"";
+            $where = ""category_id = ?"";
+            $objQuery->update(""dtb_category"", $sqlval, $where, array($sqlval['category_id']));
+        } else {
+            // 新規登録
+
+            $sqlval['create_date'] = $time;
+            if($arrRet['rank'] == """"){
+                // カテゴリ内で最大のランクを割り当てる
+                $sqlval['rank'] = $objQuery->max(""dtb_category"", ""rank"", ""parent_category_id = ?"", array($arrRet['parent_category_id'])) + 1;
+            }
+            // INSERTの実行
+            $objQuery->insert(""dtb_category"", $sqlval);
+        }
+    }
+
+    /**
+     * 入力チェックを行う.
+     *
+     * @return void
+     */
+    function lfCheckError() {
+        // 入力データを渡す。
+        $arrRet =  $this->objFormParam->getHashArray();
+        $objErr = new SC_CheckError($arrRet);
+        $objErr->arrErr = $this->objFormParam->checkError(false);
+        if(count($objErr->arrErr) == 0) {
+            $objQuery = new SC_Query();
+            // 存在する親カテゴリIDかチェック
+            if($arrRet['parent_category_id'] != 0){
+                $count = $objQuery->count(""dtb_category"", ""category_id = ?"", array($arrRet['parent_category_id']));
+                if($count == 0) {
+                    $objErr->arrErr['parent_category_id'] = ""※ 指定の親カテゴリID("".$arrRet['parent_category_id']."")は、存在しません。"";
+                }
+            }
+        }
+        return $objErr->arrErr;
+    }
+
+    /**
+     * CSVのカウント数を得る.
+     *
+     * @param string $file_name ファイルパス
+     * @return integer CSV のカウント数
+     */
+    function lfCSVRecordCount($file_name) {
+
+        $count = 0;
+        $fp = fopen($file_name, ""r"");
+        while(!feof($fp)) {
+            $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
+            $count++;
+        }
+
+        return $count-1;
+    }
+
+    /**
+     * 引数の文字列をエラー出力する.
+     *
+     * 引数 $val の内容は, htmlspecialchars() によってサニタイズされ
+     *
+     * @param string $val 出力する文字列
+     * @return void
+     */
+    function printError($val) {
+        echo ""<font color=\""red\"">""
+        . htmlspecialchars($val, ENT_QUOTES)
+        . ""</font></br>\n"";
+    }
+}
+?>
diff -urN eccube-2.0.1.org/html/admin/products/upload_csv_category.php eccube-2.0.1/html/admin/products/upload_csv_category.php
--- eccube-2.0.1.org/html/admin/products/upload_csv_category.php	1970-01-01 09:00:00.000000000 +0900
+++ eccube-2.0.1/html/admin/products/upload_csv_category.php	2008-02-01 11:54:42.000000000 +0900
@@ -0,0 +1,35 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(""../../require.php"");
+require_once(CLASS_EX_PATH . ""page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php"");
+
+// }}}
+// {{{ generate page
+
+$objPage = new LC_Page_Admin_Products_UploadCSVCategory_Ex();
+register_shutdown_function(array($objPage, ""destroy""));
+$objPage->init();
+$objPage->process();
+?>

}}}

パッチは少し長くなってしまったので添付もします。
"	新規開発	closed	中	EC-CUBE2.x.x	管理画面	2.0.1(正式版)	修正済			
