Ignore:
Timestamp:
2009/12/07 15:08:06 (14 years ago)
Author:
kajiwara
Message:

EC-CUBE Ver2.4.2 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=207

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2/data/class/pages/products/LC_Page_Products_List.php

    r18177 r18432  
    246246            $tpl_subtitle = "検索結果"; 
    247247            $tpl_search_mode = true; 
    248         }elseif (empty($arrCategory_id)) { 
     248        }elseif (empty($arrCategory_id[0])) { 
    249249            $tpl_subtitle = "全商品"; 
    250250        }else{ 
     
    380380        $objDb = new SC_Helper_DB_Ex(); 
    381381        $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno']; 
    382  
    383         //表示順序 
    384         switch($orderby) { 
    385  
    386         //価格順 
    387         case 'price': 
    388             $col = "DISTINCT price02_min, product_id, product_code_min, product_code_max," 
    389                 . " name, comment1, comment2, comment3," 
    390                 . " main_list_comment, main_image, main_list_image," 
    391                 . " price01_min, price01_max, price02_max," 
    392                 . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max," 
    393                 . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee," 
    394                 . " status, product_flag, create_date, del_flg"; 
    395             $from = "vw_products_allclass AS T1"; 
    396             $order = "price02_min, product_id"; 
    397             break; 
    398  
    399         //新着順 
    400         case 'date': 
    401             $col = "DISTINCT create_date, product_id, product_code_min, product_code_max," 
    402                 . " name, comment1, comment2, comment3," 
    403                 . " main_list_comment, main_image, main_list_image," 
    404                 . " price01_min, price01_max, price02_min, price02_max," 
    405                 . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max," 
    406                 . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee," 
    407                 . " status, product_flag, del_flg"; 
    408             $from = "vw_products_allclass AS T1"; 
    409             $order = "create_date DESC, product_id"; 
    410             break; 
    411  
    412         default: 
    413             $col = "DISTINCT T1.product_id, product_code_min, product_code_max," 
    414                 . " price01_min, price01_max, price02_min, price02_max," 
    415                 . " stock_min, stock_max, stock_unlimited_min," 
    416                 . " stock_unlimited_max, del_flg, status, name, comment1," 
    417                 . " comment2, comment3, main_list_comment, main_image," 
    418                 . " main_list_image, product_flag, deliv_date_id, sale_limit," 
    419                 . " point_rate, sale_unlimited, create_date, deliv_fee, " 
    420                 . " T4.product_rank, T4.category_rank"; 
    421             $from = "vw_products_allclass AS T1" 
    422                 . " JOIN (" 
    423                 . " SELECT max(T3.rank) AS category_rank," 
    424                 . "        max(T2.rank) AS product_rank," 
    425                 . "        T2.product_id" 
    426                 . "   FROM dtb_product_categories T2" 
    427                 . "   JOIN dtb_category T3 USING (category_id)" 
    428                 . " GROUP BY product_id) AS T4 USING (product_id)"; 
    429             $order = "T4.category_rank DESC, T4.product_rank DESC"; 
    430             break; 
    431         } 
    432  
     382        $arrval = array(); 
     383        $arrval_order = array(); 
     384        $arrval_category = array(); 
     385 
     386        // カテゴリからのWHERE文字列取得 
     387 
     388        if ( $category_id ) { 
     389            list($tmp_where, $arrval_category) = $objDb->sfGetCatWhere($category_id); 
     390            if (strlen($tmp_where) >= 1) { 
     391                $where_category = "AND $tmp_where"; 
     392                //並び替え用(MySQL4.1対応) 
     393                $where_category_order = "AND " ."T2.".trim($tmp_where); 
     394            } 
     395        } 
     396 
     397        // ▼対象商品IDの抽出 
    433398        // 商品検索条件の作成(未削除、表示) 
    434399        $where = "del_flg = 0 AND status = 1 "; 
    435         // カテゴリからのWHERE文字列取得 
    436         if ( $category_id ) { 
    437             list($tmp_where, $arrval) = $objDb->sfGetCatWhere($category_id); 
    438             if($tmp_where != "") { 
    439                 $where.= " AND $tmp_where"; 
    440             } 
     400 
     401        // 在庫無し商品の非表示 
     402        if (NOSTOCK_HIDDEN === true) { 
     403            $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; 
     404        } 
     405 
     406        if (strlen($where_category) >= 1) { 
     407            $where.= " $where_category"; 
     408            $arrval = array_merge($arrval, $arrval_category); 
    441409        } 
    442410 
     
    457425        } 
    458426 
    459         if (empty($arrval)) { 
    460             $arrval = array(); 
    461         } 
     427        $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); 
     428        // ▲対象商品IDの抽出 
    462429 
    463430        // 行数の取得 
    464         $linemax = count($objQuery->getAll("SELECT DISTINCT product_id " 
    465                                          . "FROM vw_products_allclass AS allcls " 
    466                                          . (!empty($where) ? " WHERE " . $where 
    467                                                            : ""), $arrval)); 
     431        $linemax = count($arrProduct_id); 
    468432 
    469433        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
     
    478442        $startno = $this->objNavi->start_row;                 // 開始行 
    479443 
     444        // ▼商品詳細取得 
     445        $col = <<< __EOS__ 
     446             product_id 
     447            ,product_code_min 
     448            ,product_code_max 
     449            ,name 
     450            ,comment1 
     451            ,comment2 
     452            ,comment3 
     453            ,main_list_comment 
     454            ,main_image 
     455            ,main_list_image 
     456            ,price01_min 
     457            ,price01_max 
     458            ,price02_min 
     459            ,price02_max 
     460            ,stock_min 
     461            ,stock_max 
     462            ,stock_unlimited_min 
     463            ,stock_unlimited_max 
     464            ,point_rate 
     465            ,sale_limit 
     466            ,sale_unlimited 
     467            ,deliv_date_id 
     468            ,deliv_fee 
     469            ,status 
     470            ,product_flag 
     471            ,del_flg 
     472__EOS__; 
     473 
     474        $from = "vw_products_allclass_detail AS alldtl"; 
     475 
     476        // WHERE 句 
     477        $where = '0=0'; 
     478        if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 
     479            $where .= ' AND product_id IN (' . implode(',', $arrProduct_id) . ')'; 
     480        } 
     481 
     482        //表示順序 
     483        switch($orderby) { 
     484 
     485            //販売価格順 
     486            case 'price': 
     487                $order = "price02_min, product_id"; 
     488                break; 
     489 
     490            //新着順 
     491            case 'date': 
     492                $order = "create_date DESC, product_id"; 
     493                break; 
     494 
     495            default: 
     496                $order = <<< __EOS__ 
     497                    ( 
     498                        SELECT 
     499                             T3.rank 
     500                        FROM 
     501                            dtb_product_categories T2 
     502                            JOIN dtb_category T3 
     503                                USING (category_id) 
     504                        WHERE T2.product_id = alldtl.product_id 
     505                            $where_category_order 
     506                        ORDER BY T3.rank DESC, T2.rank DESC 
     507                        LIMIT 1 
     508                    ) DESC 
     509                    ,( 
     510                        SELECT 
     511                            T2.rank 
     512                        FROM 
     513                            dtb_product_categories T2 
     514                            JOIN dtb_category T3 
     515                                USING (category_id) 
     516                        WHERE T2.product_id = alldtl.product_id 
     517                            $where_category_order 
     518                        ORDER BY T3.rank DESC, T2.rank DESC 
     519                        LIMIT 1 
     520                    ) DESC 
     521                    ,product_id 
     522__EOS__; 
     523                $arrval_order = array_merge($arrval_category, $arrval_category); 
     524                break; 
     525        } 
     526 
    480527        // 取得範囲の指定(開始行番号、行数のセット) 
    481528        $objQuery->setlimitoffset($disp_num, $startno); 
     
    484531 
    485532        // 検索結果の取得 
    486         $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); 
     533        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); 
     534        // ▲商品詳細取得 
    487535 
    488536        // 規格名一覧 
Note: See TracChangeset for help on using the changeset viewer.