Ignore:
Timestamp:
2013/02/26 09:09:44 (11 years ago)
Author:
pineray
Message:

#2162 pageクラスからdtb_best_productsテーブルを直接指定している箇所をなくす

File:
1 edited

Legend:

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

    r22567 r22582  
    9494    function lfGetRanking() 
    9595    { 
    96         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    97         $objProduct = new SC_Product_Ex(); 
     96        $objRecommend = new SC_Helper_Recommend_Ex(); 
    9897 
    9998        // おすすめ商品取得 
    100         $col = 'T1.best_id, T1.category_id, T1.rank, T1.product_id, T1.title, T1.comment, T1.create_date, T1.update_date'; 
    101         $table = 'dtb_best_products as T1 INNER JOIN dtb_products as T2 ON T1.product_id = T2.product_id'; 
    102         $where = 'T1.del_flg = 0 and T2.status = 1'; 
    103         if (NOSTOCK_HIDDEN) { 
    104             $where .= ' AND EXISTS(SELECT * FROM dtb_products_class WHERE product_id = T1.product_id AND dtb_products_class.del_flg = 0 AND (stock >= 1 OR stock_unlimited = 1))'; 
    105         } 
    106         $objQuery->setOrder('T1.rank'); 
    107         $objQuery->setLimit(RECOMMEND_NUM); 
    108         $arrBestProducts = $objQuery->select($col, $table, $where); 
     99        $arrRecommends = $objRecommend->getList(RECOMMEND_NUM); 
    109100 
    110         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    111         if (count($arrBestProducts) > 0) { 
     101        $response = array(); 
     102        if (count($arrRecommends) > 0) { 
    112103            // 商品一覧を取得 
     104            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     105            $objProduct = new SC_Product_Ex(); 
    113106            // where条件生成&セット 
    114107            $arrProductId = array(); 
    115             $where = 'product_id IN ('; 
    116             foreach ($arrBestProducts as $key => $val) { 
     108            foreach ($arrRecommends as $key => $val) { 
    117109                $arrProductId[] = $val['product_id']; 
    118110            } 
    119             // 取得 
    120             $arrProductList = $objProduct->getListByProductIds($objQuery, $arrProductId); 
     111            $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId); 
     112 
     113            // 税込金額を設定する 
     114            SC_Product_Ex::setIncTaxToProducts($arrProducts); 
     115 
    121116            // おすすめ商品情報にマージ 
    122             foreach ($arrBestProducts as $key => $value) { 
    123                 $arrRow =& $arrBestProducts[$key]; 
    124                 if (isset($arrProductList[$arrRow['product_id']])) { 
    125                     $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]); 
     117            foreach ($arrRecommends as $key => $value) { 
     118                if (isset($arrProducts[$value['product_id']])) { 
     119                    $product = $arrProducts[$value['product_id']]; 
     120                    if (!NOSTOCK_HIDDEN || ($product['status'] == 1 && ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) { 
     121                        $response[] = array_merge($value, $arrProducts[$value['product_id']]); 
     122                    } 
    126123                } else { 
    127124                    // 削除済み商品は除外 
    128                     unset($arrBestProducts[$key]); 
     125                    unset($arrRecommends[$key]); 
    129126                } 
    130127            } 
    131128        } 
    132         return $arrBestProducts; 
     129        return $response; 
    133130    } 
    134131} 
Note: See TracChangeset for help on using the changeset viewer.