Changeset 17206


Ignore:
Timestamp:
2008/04/04 15:41:15 (16 years ago)
Author:
satou
Message:

fixed by Yammy (merge r17155)

Location:
branches/version-2/data/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2/data/class/helper/SC_Helper_CSV.php

    r16741 r17206  
    105105 
    106106        $from = "vw_product_class AS prdcls"; 
    107         $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols); 
     107        $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id')); 
    108108 
    109109        $objQuery = new SC_Query(); 
     
    114114 
    115115        // 規格分類名一覧 
    116         $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
     116        if (!empty($arrOutputCols['classcategory_id1']) || !empty($arrOutputCols['classcategory_id2'])) { 
     117            $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
     118        } 
    117119 
    118120        if (!isset($data)) $data = ""; 
    119121        for($i = 0; $i < $max; $i++) { 
    120122            // 関連商品情報の付与 
    121             $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']]; 
    122             $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']]; 
    123  
    124             $arrCategory_id = $objQuery->getCol("dtb_product_categories", 
    125                               "category_id", 
    126                               "product_id = ?", 
    127                               array($list_data[$i]['product_id'])); 
    128  
    129             // カテゴリID 付与 
    130             for ($j = 0; $j < count($arrCategory_id); $j++) { 
    131                 $list_data[$i]['category_id'] .= $arrCategory_id[$j]; 
    132                 if ($j < count($arrCategory_id) - 1) { 
    133                     $list_data[$i]['category_id'] .= "|"; 
     123            if (in_array('classcategory_id1', $arrOutputCols)) { 
     124                $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']]; 
     125            } 
     126            if (in_array('classcategory_id2', $arrOutputCols)) { 
     127                $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']]; 
     128            } 
     129 
     130            if (in_array('category_id', $arrOutputCols)) { 
     131                $arrCategory_id = $objQuery->getCol("dtb_product_categories", 
     132                                  "category_id", 
     133                                  "product_id = ?", 
     134                                  array($list_data[$i]['product_id'])); 
     135 
     136                // カテゴリID 付与 
     137                for ($j = 0; $j < count($arrCategory_id); $j++) { 
     138                    $list_data[$i]['category_id'] .= $arrCategory_id[$j]; 
     139                    if ($j < count($arrCategory_id) - 1) { 
     140                        $list_data[$i]['category_id'] .= "|"; 
     141                    } 
    134142                } 
    135143            } 
    136144 
    137145            // 各項目をCSV出力用に変換する。 
    138             $data .= $this->lfMakeProductsCSV($list_data[$i]); 
     146            $data .= $this->lfMakeProductsCSV($list_data[$i], $arrOutputCols); 
    139147        } 
    140148        return $data; 
     
    223231 
    224232    // 各項目をCSV出力用に変換する。(商品) 
    225     function lfMakeProductsCSV($list) { 
     233    function lfMakeProductsCSV($list, $arrOutputCols) { 
    226234        $line = ""; 
    227235        if(is_array($list)) { 
    228             foreach($list as $key => $val) { 
     236            foreach($arrOutputCols as $key) { 
    229237                $tmp = ""; 
    230238                switch($key) { 
     
    233241                        $tmp = '0'; 
    234242                    } else { 
    235                         $tmp = $val; 
     243                        $tmp = $list[$key]; 
    236244                    } 
    237245                    break; 
    238246                default: 
    239                     $tmp = $val; 
     247                    $tmp = $list[$key]; 
    240248                    break; 
    241249                } 
  • branches/version-2/data/class/util/SC_Utils.php

    r17199 r17206  
    489489 
    490490    // 配列の値をカンマ区切りで返す。 
    491     function sfGetCommaList($array, $space=true) { 
     491    function sfGetCommaList($array, $space=true, $arrPop = array()) { 
    492492        if (count($array) > 0) { 
    493493            $line = ""; 
    494494            foreach($array as $val) { 
    495                 if ($space) { 
    496                     $line .= $val . ", "; 
    497                 }else{ 
    498                     $line .= $val . ","; 
     495                if (!in_array($val, $arrPop)) { 
     496                    if ($space) { 
     497                        $line .= $val . ", "; 
     498                    } else { 
     499                        $line .= $val . ","; 
     500                    } 
    499501                } 
    500502            } 
    501503            if ($space) { 
    502504                $line = ereg_replace(", $", "", $line); 
    503             }else{ 
     505            } else { 
    504506                $line = ereg_replace(",$", "", $line); 
    505507            } 
    506508            return $line; 
    507         }else{ 
     509        } else { 
    508510            return false; 
    509511        } 
Note: See TracChangeset for help on using the changeset viewer.