Ignore:
Timestamp:
2007/10/24 14:01:35 (17 years ago)
Author:
nanasess
Message:

複数カテゴリ対応

Location:
branches/feature-module-update/data/class/pages
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products.php

    r16379 r16546  
    169169                            break; 
    170170                        case 'search_category_id':  // カテゴリー 
    171                             list($tmp_where, $tmp_arrval) = SC_Utils_Ex::sfGetCatWhere($val); 
     171                            list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); 
    172172                            if($tmp_where != "") { 
    173                                 $where.= " AND $tmp_where"; 
    174                                 $view_where.= " AND $tmp_where"; 
     173                                $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; 
     174                                $view_where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; 
    175175                                $arrval = array_merge((array)$arrval, (array)$tmp_arrval); 
    176176                            } 
     
    260260                    // 読み込む列とテーブルの指定 
    261261                    $col = "product_id, name, category_id, main_list_image, status, product_code, price01, price02, stock, stock_unlimited"; 
    262                     $from = "vw_products_nonclass AS noncls "; 
     262                    $from = "vw_products_nonclass AS allcls "; 
    263263 
    264264                    // 行数の取得 
  • branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php

    r15556 r16546  
    312312        $where = "product_id = ?"; 
    313313 
    314         // viewも絞込み(mysql対応) TODO 
    315         //sfViewWhere("&&noncls_where&&", $where, array($product_id)); 
    316  
    317314        $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 
     315 
     316        // カテゴリID を取得 
     317        $arrRet[0]['category_id'] = $objQuery->getCol("dtb_product_categories", 
     318                                                      "category_id", 
     319                                                      "product_id = ?", 
     320                                                      array($product_id)); 
    318321 
    319322        return $arrRet[0]; 
     
    327330        list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false); 
    328331 
     332        if (isset($this->arrForm['category_id']) && !is_array($this->arrForm['category_id'])) { 
     333            $this->arrForm['category_id'] = unserialize($this->arrForm['category_id']); 
     334        } 
    329335        if($this->arrForm['status'] == "") { 
    330336            $this->arrForm['status'] = 1; 
     
    351357        } 
    352358 
    353         $this->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); " . $anchor_hash; 
     359        $this->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash; 
    354360    } 
    355361 
     
    374380 
    375381        // 配列の添字を定義 
    376         $checkArray = array("name", "category_id", "status", "product_flag", 
     382        $checkArray = array("name", "status", "product_flag", 
    377383                            "main_list_comment", "main_comment", "point_rate", 
    378384                            "deliv_fee", "comment1", "comment2", "comment3", 
     
    383389        // INSERTする値を作成する。 
    384390        $sqlval['name'] = $arrList['name']; 
    385         $sqlval['category_id'] = $arrList['category_id']; 
     391        //$sqlval['category_id'] = $arrList['category_id']; 
    386392        $sqlval['status'] = $arrList['status']; 
    387393        $sqlval['product_flag'] = $arrList['product_flag']; 
     
    416422            } 
    417423            // カテゴリ内で最大のランクを割り当てる 
    418             $sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrList['category_id'])) + 1; 
     424            //$sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrList['category_id'])) + 1; 
     425 
    419426            // INSERTの実行 
    420427            $sqlval['create_date'] = "Now()"; 
    421428            $objQuery->insert("dtb_products", $sqlval); 
    422429 
     430            // カテゴリを更新 
     431            $objDb->updateProductCategories($arrList['category_id'], $sqlval['product_id']); 
     432 
    423433            if (DB_TYPE == "mysql") { 
    424434                $product_id = $objQuery->nextval("dtb_products", "product_id"); 
     
    427437 
    428438            // コピー商品の場合には規格もコピーする 
    429             if($_POST["copy_product_id"] != "" and sfIsInt($_POST["copy_product_id"])){ 
     439            if($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])){ 
    430440                // dtb_products_class のカラムを取得 
    431441                $dbFactory = SC_DB_DBFactory::getInstance(); 
     
    449459            $this->objUpFile->deleteDBFile($arrRet); 
    450460 
    451             // カテゴリ内ランクの調整処理 
    452             $old_catid = $objQuery->get("dtb_products", "category_id", "product_id = ?", array($arrList['product_id'])); 
    453             $objDb->sfMoveCatRank($objQuery, "dtb_products", "product_id", "category_id", $old_catid, $arrList['category_id'], $arrList['product_id']); 
    454  
     461            $arrList['category_id'] = unserialize($arrList['category_id']); 
    455462            // UPDATEの実行 
    456463            $where = "product_id = ?"; 
    457464            $objQuery->update("dtb_products", $sqlval, $where, array($arrList['product_id'])); 
     465 
     466            // カテゴリを更新 
     467            $objDb->updateProductCategories($arrList['category_id'], $arrList['product_id']); 
    458468        } 
    459469 
     
    526536        $objErr = new SC_CheckError($array); 
    527537        $objErr->doFunc(array("商品名", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    528         $objErr->doFunc(array("商品カテゴリ", "category_id", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     538        //$objErr->doFunc(array("商品カテゴリ", "category_id", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    529539        $objErr->doFunc(array("一覧-メインコメント", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    530540        $objErr->doFunc(array("詳細-メインコメント", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     
    549559            $objErr->doFunc(array("購入制限", "sale_limit", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    550560        } 
    551  
     561        /* 
    552562        if(isset($objErr->arrErr['category_id'])) { 
    553563            // 自動選択を防ぐためにダミー文字を入れておく 
    554564            $this->arrForm['category_id'] = "#"; 
    555565        } 
    556  
     566        */ 
    557567        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { 
    558568            $objErr->doFunc(array("詳細-サブタイトル$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     
    572582        } 
    573583 
     584        // カテゴリID のチェック 
     585        if (empty($array['category_id'])) { 
     586            $objErr->arrErr['category_id'] = "※ カテゴリが選択されていません。<br />"; 
     587        } else { 
     588            $arrCategory_id = array(); 
     589            for ($i = 0; $i < count($array['category_id']); $i++) { 
     590                $arrCategory_id['category_id' . $i] = $array['category_id'][$i]; 
     591            } 
     592            $objCheckCategory = new SC_CheckError($arrCategory_id); 
     593            for ($i = 0; $i < count($array['category_id']); $i++) { 
     594                $objCheckCategory->doFunc(array("商品カテゴリ", "category_id" . $i, STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     595            } 
     596            if (!empty($objCheckCategory->arrErr)) { 
     597                $objErr->arrErr = array_merge($objErr->arrErr, 
     598                                              $objCheckCategory->arrErr); 
     599            } 
     600        } 
    574601        return $objErr->arrErr; 
    575602    } 
     
    579606        $this->tpl_mainpage = 'products/confirm.tpl'; 
    580607        $this->arrForm['mode'] = 'complete'; 
     608 
    581609        $objDb = new SC_Helper_DB_Ex(); 
    582         // カテゴリの読込 
    583         $this->arrCatList = $objDb->sfGetCategoryList(); 
     610 
     611        // カテゴリ表示 
     612        $this->arrCategory_id = $this->arrForm['category_id']; 
     613        $this->arrCatList = array(); 
     614        list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false); 
     615        for ($i = 0; $i < count($arrCatVal); $i++) { 
     616            $this->arrCatList[$arrCatVal[$i]] = $arrCatOut[$i]; 
     617        } 
     618 
     619        // hidden に渡す値は serialize する 
     620        $this->arrForm['category_id'] = serialize($this->arrForm['category_id']); 
     621 
    584622        // Form用配列を渡す。 
    585623        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); 
  • branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_ProductRank.php

    r15532 r16546  
    5858        switch($_POST['mode']) { 
    5959        case 'up': 
    60             $where = "category_id = " . addslashes($_POST['parent_category_id']); 
    61             $objDb->sfRankUp("dtb_products", "product_id", $_POST['product_id'], $where); 
     60            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); 
     61            $objDb->sfRankUp("dtb_product_categories", "product_id", $_POST['product_id'], $where); 
    6262            break; 
    6363        case 'down': 
    64             $where = "category_id = " . addslashes($_POST['parent_category_id']); 
    65             $objDb->sfRankDown("dtb_products", "product_id", $_POST['product_id'], $where); 
     64            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); 
     65            $objDb->sfRankDown("dtb_product_categories", "product_id", $_POST['product_id'], $where); 
    6666            break; 
    6767        case 'move': 
     
    6969            $input_pos = mb_convert_kana($_POST[$key], "n"); 
    7070            if(SC_Utils_Ex::sfIsInt($input_pos)) { 
    71                 $where = "category_id = " . addslashes($_POST['parent_category_id']); 
    72                 $objDb->sfMoveRank("dtb_products", "product_id", $_POST['product_id'], $input_pos, $where); 
     71                $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']); 
     72                $objDb->sfMoveRank("dtb_product_categories", "product_id", $_POST['product_id'], $input_pos, "category_id = ?"); 
    7373            } 
    7474            break; 
     
    101101    function lfGetProduct($category_id) { 
    102102        $objQuery = new SC_Query(); 
    103         $col = "product_id, name, main_list_image, rank, product_code"; 
    104         $table = "vw_products_nonclass AS noncls "; 
     103        $col = "product_id, name, main_list_image, rank"; 
     104        $table = "vw_products_allclass "; 
    105105        $where = "del_flg = 0 AND category_id = ?"; 
    106106 
    107107        // 行数の取得 
    108         $linemax = $objQuery->count("dtb_products", $where, array($category_id)); 
     108        $linemax = $objQuery->count("dtb_product_categories", "category_id = ?", array($category_id)); 
    109109        // 順位、該当件数表示用 
    110110        $this->tpl_linemax = $linemax; 
  • branches/feature-module-update/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php

    r16530 r16546  
    8888        $objQuery = new SC_Query(); 
    8989 
    90         $col = "A.*, name, price02_min, price01_min, main_list_image "; 
     90        $col = "DISTINCT A.*, name, price02_min, price01_min, main_list_image "; 
    9191        $from = "dtb_best_products AS A INNER JOIN vw_products_allclass AS allcls using(product_id)"; 
    9292        $where = "status = 1"; 
  • branches/feature-module-update/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php

    r16530 r16546  
    4242 
    4343        // 選択中のカテゴリIDを判定する 
    44         $category_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
     44        $arrCategory_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
    4545 
    4646        // 選択中のカテゴリID 
    47         $this->tpl_category_id = $category_id; 
    48         $objPage = $this->lfGetCatTree($category_id, true, $this); 
     47        $this->tpl_category_id = empty($arrCategory_id) ? array(0) : $arrCategory_id;; 
     48        $this->lfGetCatTree($this->tpl_category_id, true, $this); 
    4949 
    50         $objSubView->assignobj($objPage); 
     50        $objSubView->assignobj($this); 
    5151        $objSubView->display($this->tpl_mainpage); 
    5252    } 
     
    8686 
    8787    // カテゴリツリーの取得 
    88     function lfGetCatTree($parent_category_id, $count_check = false, $objSubPage) { 
     88    function lfGetCatTree($arrParent_category_id, $count_check = false) { 
    8989        $objQuery = new SC_Query(); 
    9090        $objDb = new SC_Helper_DB_Ex(); 
     
    100100        $arrRet = $objQuery->select($col, $from, $where); 
    101101 
    102         $arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    103         $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID); 
    104         $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $parent_category_id); 
     102        foreach ($arrParent_category_id as $category_id) { 
     103            $arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); 
     104            $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID); 
     105            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id); 
    105106 
    106         $objSubPage->root_parent_id = $arrParentID[0]; 
     107            $this->root_parent_id[] = $arrParentID[0]; 
    107108 
    108         $arrDispID = array_merge($arrBrothersID, $arrChildrenID); 
     109            $arrDispID = array_merge($arrBrothersID, $arrChildrenID); 
    109110 
    110         foreach($arrRet as $key => $array) { 
    111             foreach($arrDispID as $val) { 
    112                 if($array['category_id'] == $val) { 
    113                     $arrRet[$key]['display'] = 1; 
    114                     break; 
     111            foreach($arrRet as $key => $array) { 
     112                foreach($arrDispID as $val) { 
     113                    if($array['category_id'] == $val) { 
     114                        $arrRet[$key]['display'] = 1; 
     115                        break; 
     116                    } 
    115117                } 
    116118            } 
    117119        } 
    118120 
    119         $objSubPage->arrTree = $arrRet; 
    120         return $objSubPage; 
     121        $this->arrTree = $arrRet; 
    121122    } 
    122123 
  • branches/feature-module-update/data/class/pages/products/LC_Page_Products_CategoryList.php

    r16166 r16546  
    8888        $objDb = new SC_Helper_DB_Ex(); 
    8989        // カテゴリーの正しいIDを取得する。 
    90         $category_id = $objDb->sfGetCategoryId('', $category_id); 
     90        $arrCategory_id = $objDb->sfGetCategoryId('', $category_id); 
     91        $category_id = $arrCategory_id[0]; 
    9192        if ($category_id == 0) { 
    9293            SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND, "", false, "", true); 
  • branches/feature-module-update/data/class/pages/products/LC_Page_Products_Detail.php

    r16398 r16546  
    188188 
    189189        // サブタイトルを取得 
    190         $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); 
     190        $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id']); 
     191        $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 
    191192        $this->tpl_subtitle = $arrFirstCat['name']; 
    192193 
     
    621622        $arrSele1 = array(); 
    622623        $arrSele2 = array(); 
    623         $arrList = array(); 
    624  
    625         $list_id = 0; 
    626         $arrList[0] = "\tlist0 = new Array('選択してください'"; 
    627         $arrVal[0] = "\tval0 = new Array(''"; 
    628624 
    629625        for ($i = 0; $i < $count; $i++) { 
     
    637633            // 規格1のセレクトボックス用 
    638634            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 
    639                 $arrList[$list_id].=");\n"; 
    640                 $arrVal[$list_id].=");\n"; 
    641635                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 
    642636                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1]; 
     
    648642                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2]; 
    649643            } 
    650  
    651             $list_id++; 
    652  
    653             // セレクトボックス表示値 
    654             if($arrList[$list_id] == "") { 
    655                 $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'"; 
    656             } else { 
    657                 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 
    658             } 
    659  
    660             // セレクトボックスPOST値 
    661             if($arrVal[$list_id] == "") { 
    662                 $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'"; 
    663             } else { 
    664                 $arrVal[$list_id].= ", '".$classcat_id2."'"; 
    665             } 
    666         } 
    667  
    668         //$arrList[$list_id].=");\n"; 
    669         $arrVal[$list_id].=");\n"; 
     644        } 
    670645 
    671646        // 規格1 
     
    718693        $max = count($arrRet); 
    719694        $no = 0; 
     695        $from = "vw_products_allclass AS T1 " 
     696                . " JOIN (" 
     697                . " SELECT max(T2.rank) AS product_rank, " 
     698                . "        T2.product_id" 
     699                . "   FROM dtb_product_categories T2  " 
     700                . " GROUP BY product_id) AS T3 USING (product_id)"; 
     701        $objQuery->setorder("product_rank DESC"); 
    720702        for($i = 0; $i < $max; $i++) { 
    721703            $where = "del_flg = 0 AND product_id = ? AND status = 1"; 
    722             $arrProductInfo = $objQuery->select("main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate", "vw_products_allclass  AS allcls", $where, array($arrRet[$i]['recommend_product_id'])); 
     704            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, product_rank", $from, $where, array($arrRet[$i]['recommend_product_id'])); 
    723705 
    724706            if(count($arrProductInfo) > 0) { 
     
    760742    } 
    761743 
    762     //この商品を買った人はこんな商品も買っています 
     744    //この商品を買った人はこんな商品も買っています FIXME 
    763745    function lfGetRelateProducts($tmp_id) { 
    764746        $objQuery = new SC_Query; 
  • branches/feature-module-update/data/class/pages/products/LC_Page_Products_List.php

    r16270 r16546  
    7373 
    7474        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    75         $category_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
     75        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
    7676 
    7777        if (!isset($_GET['mode'])) $_GET['mode'] = ""; 
    7878        if (!isset($_GET['name'])) $_GET['name'] = ""; 
    7979        if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; 
     80        if (empty($arrCategory_id)) $arrCategory_id = array(""); 
    8081 
    8182        // タイトル編集 
     
    8384        if ($_GET['mode'] == 'search') { 
    8485            $tpl_subtitle = "検索結果"; 
    85         } elseif ($category_id == "" ) { 
     86        } elseif (empty($arrCategory_id)) { 
    8687            $tpl_subtitle = "全商品"; 
    8788        } else { 
    88             $arrFirstCat = $objDb->sfGetFirstCat($category_id); 
     89            $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 
    8990            $tpl_subtitle = $arrFirstCat['name']; 
    9091        } 
    9192 
    9293        $objQuery = new SC_Query(); 
    93         $count = $objQuery->count("dtb_best_products", "category_id = ?", array($category_id)); 
     94        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 
    9495 
    9596        // 以下の条件でBEST商品を表示する 
     
    9798        // ・カテゴリIDがルートIDである。 
    9899        // ・検索モードでない。 
    99         if(($count >= BEST_MIN) && $this->lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
     100        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 
    100101            // 商品TOPの表示処理 
    101             $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $category_id); 
     102            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 
    102103            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    103104        } else { 
    104105            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    105106                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    106                 $category_id = ''; 
     107                $arrCategory_id = array(0); 
    107108            } 
    108109 
    109110            // 商品一覧の表示処理 
    110             $this->lfDispProductsList($category_id, $_GET['name'], $this->disp_number, $_POST['orderby']); 
     111            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); 
    111112 
    112113            // 検索条件を画面に表示 
     
    115116                $arrSearch['category'] = "指定なし"; 
    116117            }else{ 
    117                 $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); 
     118                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); 
    118119                $arrSearch['category'] = $arrCat; 
    119120            } 
     
    171172        $this->lfConvertParam(); 
    172173 
    173         $this->category_id = $category_id; 
     174        $this->category_id = $arrCategory_id[0]; 
    174175        $this->arrSearch = $arrSearch; 
    175176 
     
    210211 
    211212        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    212         $category_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
     213        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
    213214 
    214215        // タイトル編集 
     
    224225            $tpl_subtitle = "検索結果"; 
    225226            $tpl_search_mode = true; 
    226         }elseif ($category_id == "" ) { 
     227        }elseif (empty($arrCategory_id)) { 
    227228            $tpl_subtitle = "全商品"; 
    228229        }else{ 
    229             $arrFirstCat = $objDb->sfGetFirstCat($category_id); 
     230            $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id); 
    230231            $tpl_subtitle = $arrFirstCat['name']; 
    231232        } 
    232233 
    233234        $objQuery = new SC_Query(); 
    234         $count = $objQuery->count("dtb_best_products", "category_id = ?", array($category_id)); 
     235        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 
    235236 
    236237        // 以下の条件でBEST商品を表示する 
     
    238239        // ・カテゴリIDがルートIDである。 
    239240        // ・検索モードでない。 
    240         if(($count >= BEST_MIN) && $this->lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
     241        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 
    241242            // 商品TOPの表示処理 
    242             /** 必ず指定する **/ 
    243  
    244             $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $category_id); 
     243 
     244            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 
    245245            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    246246        } else { 
    247247            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    248248                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    249                 $category_id = ''; 
     249                $arrCategory_id = array(""); 
    250250            } 
    251251 
    252252            // 商品一覧の表示処理 
    253             $this->lfDispProductsList($category_id, $_GET['name'], $this->disp_number, $_REQUEST['orderby']); 
     253            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']); 
    254254 
    255255            // 検索条件を画面に表示 
     
    269269            } 
    270270        } 
    271  
    272         // レイアウトデザインを取得 
    273         //$layout = new SC_Helper_PageLayout_Ex(); 
    274         //$layout->sfGetPageLayout($this, false, "products/list.php"); 
    275271 
    276272        if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 
     
    331327        $this->arrForm = $_POST; 
    332328 
    333         $this->category_id = $category_id; 
     329        $this->category_id = $arrCategory_id[0]; 
    334330        $this->arrSearch = $arrSearch; 
    335331        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; 
     
    365361        //表示順序 
    366362        switch($orderby) { 
     363 
    367364        //価格順 
    368365        case 'price': 
    369             $order = "price02_min ASC"; 
     366            $distinct = "DISTINCT ON (price02_min, product_id)"; 
     367            $col = $distinct . " *"; 
     368            $from = "vw_products_allclass "; 
     369            $order = "price02_min ASC, product_id ASC"; 
    370370            break; 
     371 
    371372        //新着順 
    372373        case 'date': 
    373             $order = "create_date DESC"; 
     374            $distinct = "DISTINCT ON (create_date, product_id)"; 
     375            $col = $distinct . " *"; 
     376            $from = "vw_products_allclass "; 
     377            $order = "create_date DESC, product_id ASC"; 
    374378            break; 
     379 
    375380        default: 
    376             $order = "category_rank DESC, rank DESC"; 
     381            $col = "DISTINCT product_id, product_code_min, product_code_max," 
     382                . " price01_min, price01_max, price02_min, price02_max, " 
     383                . " stock_min, stock_max, stock_unlimited_min, " 
     384                . " stock_unlimited_max, del_flg, status, name, comment1, " 
     385                . " comment2, comment3, main_list_comment, main_image, " 
     386                . " main_list_image, product_flag, deliv_date_id, sale_limit," 
     387                . " point_rate, sale_unlimited, create_date, deliv_fee, " 
     388                . " T4.product_rank, T4.category_rank"; 
     389            $from = "vw_products_allclass AS T1 " 
     390                . " JOIN (" 
     391                . " SELECT max(T3.rank) AS category_rank, " 
     392                . "        max(T2.rank) AS product_rank, " 
     393                . "        T2.product_id" 
     394                . "   FROM dtb_product_categories T2  " 
     395                . "   JOIN dtb_category T3 USING (category_id) " 
     396                . " GROUP BY product_id) AS T4 USING (product_id)"; 
     397            $order = "T4.category_rank DESC, T4.product_rank DESC"; 
    377398            break; 
    378399        } 
     
    400421            $arrval = array(); 
    401422        } 
     423 
    402424        // 行数の取得 
    403         $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval); 
     425        $linemax = count($objQuery->getAll("SELECT DISTINCT product_id " 
     426                                         . "FROM vw_products_allclass AS allcls " 
     427                                         . (!empty($where) ? " WHERE " . $where  
     428                                                           : ""), $arrval)); 
     429 
    404430        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
    405431 
     
    419445 
    420446        // 検索結果の取得 
    421         $this->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 
     447        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); 
    422448 
    423449        // 規格名一覧 
     
    425451        // 規格分類名一覧 
    426452        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
    427         // 企画セレクトボックス設定 
     453        // 規格セレクトボックス設定 
    428454        if($disp_num == 15) { 
    429455            for($i = 0; $i < count($this->arrProducts); $i++) { 
     
    433459            } 
    434460        } 
    435  
    436         return $this; 
    437461    } 
    438462 
Note: See TracChangeset for help on using the changeset viewer.