Changeset 21143


Ignore:
Timestamp:
2011/08/08 12:35:40 (13 years ago)
Author:
Seasoft
Message:

#1427 (LC_Page_FrontParts_Bloc_Recommend#lfGetRanking 要素順が rank と一致しない)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_11-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php

    r20810 r21143  
    8686     */ 
    8787    function lfGetRanking(){ 
    88         $arrProduct = array(); 
     88        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     89        $objProduct = new SC_Product_Ex(); 
     90 
    8991        // おすすめ商品取得 
    90         $objQuery = SC_Query_Ex::getSingletonInstance(); 
    91  
    9292        $col = 'best_id, best_id, category_id, rank, product_id, title, comment, create_date, update_date'; 
    9393        $table = 'dtb_best_products'; 
     
    9696        $objQuery->setLimit(RECOMMEND_NUM); 
    9797        $arrBestProducts = $objQuery->select($col, $table, $where); 
    98         if ( is_array($arrBestProducts) && count($arrBestProducts) > 0 ) { 
    99             // 各商品の詳細情報を取得 
    100             $objQuery = SC_Query_Ex::getSingletonInstance(); 
    101             $objProduct = new SC_Product_Ex(); 
     98 
     99        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     100        if (count($arrBestProducts) > 0) { 
     101            // 商品一覧を取得 
    102102            // where条件生成&セット 
    103103            $arrBestProductIds = array(); 
    104             $where = 'product_id IN ( '; 
    105             foreach( $arrBestProducts as $key => $val ) { 
     104            $where = 'product_id IN ('; 
     105            foreach ($arrBestProducts as $key => $val) { 
    106106                $arrBestProductIds[] = $val['product_id']; 
    107107            } 
    108108            $where .= implode(', ', $arrBestProductIds); 
    109             $where .= ' )'; 
     109            $where .= ')'; 
    110110            $objQuery->setWhere($where); 
    111111            // 取得 
    112             $arrProductList = $objProduct->lists($objQuery); 
    113             // おすすめ商品情報とマージ 
    114             foreach( $arrProductList as $pdct_key => $pdct_val ) { 
    115                 foreach( $arrBestProducts as $best_key => $best_val ) { 
    116                     if ( $pdct_val['product_id'] == $best_val['product_id'] ) { 
    117                         $arrProduct[$best_key] = array_merge($best_val, $pdct_val); 
    118                         break; 
    119                     } 
     112            $arrTmp = $objProduct->lists($objQuery); 
     113            foreach ($arrTmp as $key => $arrRow) { 
     114                $arrProductList[$arrRow['product_id']] = $arrRow; 
     115            } 
     116            // おすすめ商品情報にマージ 
     117            foreach (array_keys($arrBestProducts) as $key) { 
     118                $arrRow =& $arrBestProducts[$key]; 
     119                if (isset($arrProductList[$arrRow['product_id']])) { 
     120                    $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]); 
     121                } else { 
     122                    // 削除済み商品は除外 
     123                    unset($arrBestProducts[$key]); 
    120124                } 
    121125            } 
    122126        } 
    123         return $arrProduct; 
     127        return $arrBestProducts; 
    124128    } 
    125129} 
Note: See TracChangeset for help on using the changeset viewer.