Changeset 20188


Ignore:
Timestamp:
2011/02/18 09:47:45 (13 years ago)
Author:
yomoro
Message:

#986 リファクタリング

File:
1 edited

Legend:

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

    r20169 r20188  
    9191        $sql = ''; 
    9292        $sql .= ' SELECT'; 
    93         $sql .= ' DISTINCT'; 
    9493        $sql .= '    T1.best_id,'; 
    9594        $sql .= '    T1.category_id,'; 
     
    109108        // 各商品の詳細情報を取得 
    110109        $objQuery = SC_Query::getSingletonInstance(); 
     110        $objProduct = new SC_Product(); 
     111        // where条件生成&セット 
     112        $arrBestProductIds = array(); 
     113        $where = 'product_id IN ( '; 
     114        foreach( $arrBestProducts as $key => $val ) { 
     115            $arrBestProductIds[] = $val['product_id']; 
     116        } 
     117        $where .= implode(', ', $arrBestProductIds); 
     118        $where .= ' )'; 
     119        $objQuery->setWhere($where); 
     120        // 取得 
     121        $arrProductList = $objProduct->lists($objQuery); 
     122        // おすすめ商品情報とマージ 
    111123        $arrProduct = array(); 
    112         $objProduct = new SC_Product(); 
    113         foreach( $arrBestProducts as $key => $val ) { 
    114             $where = 'product_id = ' . $val['product_id']; 
    115             $objQuery->setWhere($where); 
    116             $arrProductLsit = $objProduct->lists($objQuery); 
    117             if ( !empty($arrProductLsit) ) { 
    118                 $arrProduct[$key] = array_merge($val, $arrProductLsit[0]); 
     124        foreach( $arrProductList as $pdct_key => $pdct_val ) { 
     125            foreach( $arrBestProducts as $best_key => $best_val ) { 
     126                if ( $pdct_val['product_id'] == $best_val['product_id'] ) { 
     127                    $arrProduct[$best_key] = array_merge($best_val, $pdct_val); 
     128                    break; 
     129                } 
    119130            } 
    120131        } 
Note: See TracChangeset for help on using the changeset viewer.