Changeset 20240


Ignore:
Timestamp:
2011/02/20 06:45:20 (10 years ago)
Author:
tao
Message:

refs #982 リファクタリング 商品詳細画面

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php

    r20234 r20240  
    9595        $this->objFormParam = new SC_FormParam(); 
    9696        // パラメータ情報の初期化 
    97         $this->arrForm = $this->lfInitParam(&$this->objFormParam); 
     97        $this->arrForm = $this->lfInitParam($this->objFormParam); 
    9898        // ファイル管理クラス 
    9999        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); 
     
    429429        $objQuery->setOrder("rank DESC"); 
    430430        $arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); 
    431  
     431         
     432        $arrRecommendProductId = array(); 
     433        foreach($arrRecommendData as $recommend){ 
     434            $arrRecommendProductId[] = $recommend["recommend_product_id"]; 
     435            $arrRecommendData[$recommend["recommend_product_id"]] = $recommend["comment"]; 
     436        } 
     437         
    432438        $objProduct = new SC_Product(); 
    433  
     439         
    434440        $where = ""; 
    435         if (is_array($arrRecommendData["recommend_product_id"]) && !empty($arrRecommendData["recommend_product_id"])) { 
    436             $where = 'product_id IN (' . implode(',', $arrRecommendData["recommend_product_id"]) . ')'; 
     441        if (!empty($arrRecommendProductId)) { 
     442            $where = 'product_id IN (' . implode(',', $arrRecommendProductId) . ')'; 
    437443        } else { 
    438444            return $arrRecommend; 
     
    440446        $objQuery =& SC_Query::getSingletonInstance(); 
    441447        $objQuery->setWhere($where); 
    442         $arrProducts = $objProduct->lists($objQuery,$arrRecommendData["recommend_product_id"]); 
    443         foreach($arrProducts as $key=>$product){ 
    444             $arrProducts[$key] += array("comment"=>$arrRecommendData[$key]["comment"]);  
    445         } 
    446         return $arrProducts; 
     448        $arrProducts = $objProduct->lists($objQuery, $arrRecommendProductId); 
     449 
     450        //取得している並び順で並び替え 
     451        // FIXME SC_Productあたりにソート処理はもってくべき 
     452        $arrProducts2 = array(); 
     453        foreach($arrProducts as $item) { 
     454            $arrProducts2[ $item['product_id'] ] = $item; 
     455        } 
     456        $arrProducts = array(); 
     457        foreach($arrRecommendProductId as $product_id) { 
     458            $arrProducts2[$product_id]["comment"] = $arrRecommendData[$product_id]; 
     459            $arrRecommend[] = $arrProducts2[$product_id]; 
     460        } 
     461 
     462        return $arrRecommend; 
    447463    } 
    448464 
Note: See TracChangeset for help on using the changeset viewer.