Changeset 18130 for branches


Ignore:
Timestamp:
2009/06/19 18:16:11 (15 years ago)
Author:
kajiwara
Message:

#446 商品管理にて、複製元の商品情報を引き継いでしまう不具合を修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_4/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php

    r18120 r18130  
    450450            // コピー商品の場合には規格もコピーする 
    451451            if($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])){ 
    452                 // dtb_products_class のカラムを取得 
    453                 $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    454                 $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery); 
    455                 $arrColList_tmp = array_flip($arrColList); 
    456  
    457                 // コピーしない列 
    458                 unset($arrColList[$arrColList_tmp["product_class_id"]]);     //規格ID 
    459                 unset($arrColList[$arrColList_tmp["product_id"]]);           //商品ID 
    460                 unset($arrColList[$arrColList_tmp["create_date"]]); 
    461  
    462                 $col = SC_Utils_Ex::sfGetCommaList($arrColList); 
    463  
    464                 $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, ". $col .") SELECT ?, now(), " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"])); 
    465  
    466             } 
    467  
     452 
     453                if($this->tpl_nonclass) 
     454                { 
     455                    //規格なしの場合、コピーは価格等の入力が発生しているため、その内容で追加登録を行う 
     456                    $arrList['product_id'] = $product_id; 
     457                    $this->lfCopyProductClass($arrList, $objQuery); 
     458                } 
     459                else 
     460                { 
     461                    //規格がある場合のコピーは複製元の内容で追加登録を行う 
     462                    // dtb_products_class のカラムを取得 
     463                    $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
     464                    $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery); 
     465                    $arrColList_tmp = array_flip($arrColList); 
     466 
     467                    // コピーしない列 
     468                    unset($arrColList[$arrColList_tmp["product_class_id"]]);    //規格ID 
     469                    unset($arrColList[$arrColList_tmp["product_id"]]);            //商品ID 
     470                    unset($arrColList[$arrColList_tmp["create_date"]]); 
     471 
     472                    $col = SC_Utils_Ex::sfGetCommaList($arrColList); 
     473 
     474                    $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, ". $col .") SELECT ?, now(), " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"])); 
     475                } 
     476            } 
    468477        } else { 
    469478            $product_id = $arrList['product_id']; 
     
    723732        return $dist_name; 
    724733    } 
     734 
     735    /** 
     736    * dtb_products_classの複製 
     737    * 複製後、価格や商品コードを更新する 
     738    * 
     739    * @param array $arrList 
     740    * @param array $objQuery 
     741    * @return bool 
     742    */ 
     743    function lfCopyProductClass($arrList,$objQuery) 
     744    { 
     745        // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) 
     746        $col = "*"; 
     747        $table = "dtb_products_class"; 
     748        $where = "product_id = ?"; 
     749        $arrProductClass = $objQuery->select($col, $table, $where, array($arrList["copy_product_id"])); 
     750 
     751        //トランザクション開始 
     752        $objQuery->begin(); 
     753        $err_flag = false; 
     754        //非編集項目はコピー、編集項目は上書きして登録 
     755        foreach($arrProductClass as $records) 
     756        { 
     757            foreach($records as $key => $value) 
     758            { 
     759                if(isset($arrList[$key])) 
     760                { 
     761                    $records[$key] = $arrList[$key]; 
     762                } 
     763            } 
     764            unset($records["product_class_id"]); 
     765            unset($records["update_date"]); 
     766 
     767            $records["create_date"] = "Now()"; 
     768            $objQuery->insert($table, $records); 
     769            //エラー発生時は中断 
     770            if($objQuery->isError()) 
     771            { 
     772                $err_flag = true; 
     773                continue; 
     774            } 
     775        } 
     776        //トランザクション終了 
     777        if($err_flag) 
     778        { 
     779            $objQuery->rollback(); 
     780        } 
     781        else 
     782        { 
     783            $objQuery->commit(); 
     784        } 
     785        return !$err_flag; 
     786    } 
    725787} 
    726788?> 
Note: See TracChangeset for help on using the changeset viewer.