Ignore:
Timestamp:
2009/04/09 21:41:05 (15 years ago)
Author:
Seasoft
Message:

商品一覧
・複数のカテゴリに登録された商品をカテゴリを指定せずに検索すると、重複して表示される不具合を修正。

flealog 様のご指摘。 http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=3739&forum=1

・副作用により、パフォーマンスが改善された模様。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/pages/products/LC_Page_Products_List.php

    r17938 r17959  
    402402            } 
    403403        } 
    404  
     404         
     405        // ▼対象商品IDの抽出 
     406        // 商品検索条件の作成(未削除、表示) 
     407        $where = "del_flg = 0 AND status = 1 "; 
     408         
     409        // 在庫無し商品の非表示 
     410        if (NOSTOCK_HIDDEN === true) { 
     411            $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; 
     412        } 
     413         
     414        if (strlen($where_category) >= 1) { 
     415            $where.= " $where_category"; 
     416            $arrval = array_merge($arrval, $arrval_category); 
     417        } 
     418 
     419        // 商品名をwhere文に 
     420        $name = ereg_replace(",", "", $name);// XXX 
     421        // 全角スペースを半角スペースに変換 
     422        $name = str_replace(' ', ' ', $name); 
     423        // スペースでキーワードを分割 
     424        $names = preg_split("/ +/", $name); 
     425        // 分割したキーワードを一つずつwhere文に追加 
     426        foreach ($names as $val) { 
     427            if ( strlen($val) > 0 ){ 
     428                $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 
     429                $ret = SC_Utils_Ex::sfManualEscape($val); 
     430                $arrval[] = "%$ret%"; 
     431                $arrval[] = "%$ret%"; 
     432            } 
     433        } 
     434 
     435        // メーカーらのWHERE文字列取得 
     436        if ( $maker_id ) { 
     437            $where .= " AND maker_id = ? "; 
     438            $arrval[] = $maker_id; 
     439        } 
     440         
     441        $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); 
     442        // ▲対象商品IDの抽出 
     443         
     444        // 行数の取得 
     445        $linemax = count($arrProduct_id); 
     446 
     447        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
     448 
     449        // ページ送りの取得 
     450        $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
     451 
     452        $strnavi = $this->objNavi->strnavi; 
     453        $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
     454        // 表示文字列 
     455        $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 
     456        $startno = $this->objNavi->start_row;                 // 開始行 
     457         
     458        // ▼商品詳細取得 
    405459        $col = <<< __EOS__ 
    406460             product_id 
     
    431485            ,del_flg 
    432486__EOS__; 
    433         $from = "vw_products_allclass AS allcls"; 
     487         
     488        $from = "vw_products_allclass_detail AS alldtl"; 
     489         
     490        // WHERE 句 
     491        $where = '0=0'; 
     492        if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 
     493            $where .= ' AND product_id IN (' . implode(',', $arrProduct_id) . ')'; 
     494        } 
    434495         
    435496        //表示順序 
     
    455516                            JOIN dtb_category T3 
    456517                                USING (category_id) 
    457                         WHERE T2.product_id = allcls.product_id 
     518                        WHERE T2.product_id = alldtl.product_id 
    458519                            $where_category 
    459520                        ORDER BY T3.rank DESC, T2.rank DESC 
     
    467528                            JOIN dtb_category T3 
    468529                                USING (category_id) 
    469                         WHERE T2.product_id = allcls.product_id 
     530                        WHERE T2.product_id = alldtl.product_id 
    470531                            $where_category 
    471532                        ORDER BY T3.rank DESC, T2.rank DESC 
     
    477538                break; 
    478539        } 
    479  
    480         // 商品検索条件の作成(未削除、表示) 
    481         $where = "del_flg = 0 AND status = 1 "; 
    482          
    483         // 在庫無し商品の非表示 
    484         if (NOSTOCK_HIDDEN === true) { 
    485             $where .= ' AND (allcls.stock_max >= 1 OR allcls.stock_unlimited_max = 1)'; 
    486         } 
    487          
    488         if (strlen($where_category) >= 1) { 
    489             $where.= " $where_category"; 
    490             $arrval = array_merge($arrval, $arrval_category); 
    491         } 
    492  
    493         // 商品名をwhere文に 
    494         $name = ereg_replace(",", "", $name);// XXX 
    495         // 全角スペースを半角スペースに変換 
    496         $name = str_replace(' ', ' ', $name); 
    497         // スペースでキーワードを分割 
    498         $names = preg_split("/ +/", $name); 
    499         // 分割したキーワードを一つずつwhere文に追加 
    500         foreach ($names as $val) { 
    501             if ( strlen($val) > 0 ){ 
    502                 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 
    503                 $ret = SC_Utils_Ex::sfManualEscape($val); 
    504                 $arrval[] = "%$ret%"; 
    505                 $arrval[] = "%$ret%"; 
    506             } 
    507         } 
    508  
    509         // メーカーらのWHERE文字列取得 
    510         if ( $maker_id ) { 
    511             $where .= " AND maker_id = ? "; 
    512             $arrval[] = $maker_id; 
    513         } 
    514          
    515         // 行数の取得 
    516         $linemax = count($objQuery->getAll("SELECT DISTINCT product_id " 
    517                                          . "FROM vw_products_allclass AS allcls " 
    518                                          . (!empty($where) ? " WHERE " . $where 
    519                                                            : ""), $arrval)); 
    520  
    521         $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
    522  
    523         // ページ送りの取得 
    524         $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
    525  
    526         $strnavi = $this->objNavi->strnavi; 
    527         $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
    528         // 表示文字列 
    529         $this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi; 
    530         $startno = $this->objNavi->start_row;                 // 開始行 
    531  
     540         
    532541        // 取得範囲の指定(開始行番号、行数のセット) 
    533542        $objQuery->setlimitoffset($disp_num, $startno); 
    534543        // 表示順序 
    535544        $objQuery->setorder($order); 
    536  
     545         
    537546        // 検索結果の取得 
    538         $this->arrProducts = $objQuery->select($col, $from, $where, array_merge($arrval, $arrval_order)); 
    539  
     547        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); 
     548        // ▲商品詳細取得 
     549         
    540550        // 規格名一覧 
    541551        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 
Note: See TracChangeset for help on using the changeset viewer.