Ignore:
Timestamp:
2011/02/15 19:05:40 (13 years ago)
Author:
yomoro
Message:

リファクタリング

File:
1 edited

Legend:

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

    r20116 r20169  
    8787     */ 
    8888    function lfGetRanking(){ 
     89        // おすすめ商品取得 
    8990        $objQuery = SC_Query::getSingletonInstance(); 
    90         // FIXME SC_Product クラスを使用した実装 
    91         $col = 'DISTINCT A.*, name, price02_min, price01_min, main_list_image '; 
    92         $from = 'dtb_best_products AS A INNER JOIN vw_products_allclass AS allcls using(product_id)'; 
    93         $where = 'allcls.del_flg = 0 AND allcls.status = 1'; 
    94          
    95         // 在庫無し商品の非表示 
    96         if (NOSTOCK_HIDDEN === true) { 
    97             $where .= ' AND (allcls.stock_max >= 1 OR allcls.stock_unlimited_max = 1)'; 
     91        $sql = ''; 
     92        $sql .= ' SELECT'; 
     93        $sql .= ' DISTINCT'; 
     94        $sql .= '    T1.best_id,'; 
     95        $sql .= '    T1.category_id,'; 
     96        $sql .= '    T1.rank,'; 
     97        $sql .= '    T1.product_id,'; 
     98        $sql .= '    T1.title,'; 
     99        $sql .= '    T1.comment,'; 
     100        $sql .= '    T1.create_date,'; 
     101        $sql .= '    T1.update_date'; 
     102        $sql .= ' FROM'; 
     103        $sql .= '   dtb_best_products AS T1'; 
     104        $sql .= ' WHERE'; 
     105        $sql .= '   del_flg = 0'; 
     106        $objQuery->setOrder('rank'); 
     107        $objQuery->setLimit(RECOMMEND_NUM); 
     108        $arrBestProducts = $objQuery->getAll($sql); 
     109        // 各商品の詳細情報を取得 
     110        $objQuery = SC_Query::getSingletonInstance(); 
     111        $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]); 
     119            } 
    98120        } 
    99          
    100         $order = 'rank'; 
    101         $objQuery->setOrder($order); 
    102         $objQuery->setLimit(RECOMMEND_NUM); 
    103  
    104         $arrBestProducts = $objQuery->select($col, $from, $where); 
    105  
    106         return $arrBestProducts; 
     121        return $arrProduct; 
    107122    } 
    108123} 
Note: See TracChangeset for help on using the changeset viewer.