Ignore:
Timestamp:
2014/05/29 13:59:35 (10 years ago)
Author:
pineray
Message:

#2515 無駄な処理を改善する for 2.13.3

LC_Page_Products_Detail での関連カテゴリーの取得を、SC_Helper_Category を使った形に変更.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php

    r23457 r23458  
    371371 
    372372    /** 
    373      * カテゴリツリーの取得を複数カテゴリで行う. 
    374      * 
    375      * @param  integer $product_id  商品ID 
    376      * @param  bool    $count_check 登録商品数のチェックを行う場合 true 
    377      * @return array   カテゴリツリーの配列 
    378      */ 
    379     public static function sfGetMultiCatTree($product_id, $count_check = false) 
    380     { 
    381         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    382         $col = ''; 
    383         $col .= ' cat.category_id,'; 
    384         $col .= ' cat.category_name,'; 
    385         $col .= ' cat.parent_category_id,'; 
    386         $col .= ' cat.level,'; 
    387         $col .= ' cat.rank,'; 
    388         $col .= ' cat.creator_id,'; 
    389         $col .= ' cat.create_date,'; 
    390         $col .= ' cat.update_date,'; 
    391         $col .= ' cat.del_flg, '; 
    392         $col .= ' ttl.product_count'; 
    393         $from = 'dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id'; 
    394         // 登録商品数のチェック 
    395         if ($count_check) { 
    396             $where = 'del_flg = 0 AND product_count > 0'; 
    397         } else { 
    398             $where = 'del_flg = 0'; 
    399         } 
    400         $objQuery->setOption('ORDER BY rank DESC'); 
    401         $arrRet = $objQuery->select($col, $from, $where); 
    402  
    403         $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId($product_id); 
    404  
    405         $arrCatTree = array(); 
    406         foreach ($arrCategory_id as $pkey => $parent_category_id) { 
    407             $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    408  
    409             foreach ($arrParentID as $pid) { 
    410                 foreach ($arrRet as $key => $array) { 
    411                     if ($array['category_id'] == $pid) { 
    412                         $arrCatTree[$pkey][] = $arrRet[$key]; 
    413                         break; 
    414                     } 
    415                 } 
    416             } 
    417         } 
    418  
    419         return $arrCatTree; 
    420     } 
    421  
    422     /** 
    423373     * 親カテゴリを連結した文字列を取得する. 
    424374     * 
     
    564514     * 選択中の商品のカテゴリを取得する. 
    565515     * 
    566      * @param  integer $product_id  プロダクトID 
    567      * @param  integer $category_id カテゴリID 
    568      * @return array   選択中の商品のカテゴリIDの配列 
     516     * @param   int $product_id     プロダクトID 
     517     * @param   int $category_id    カテゴリID 
     518     * @param   bool $closed        非表示の商品を含む場合はtrue 
     519     * @return  array   選択中の商品のカテゴリIDの配列 
    569520     * 
    570521     */ 
    571522    public function sfGetCategoryId($product_id, $category_id = 0, $closed = false) 
    572523    { 
    573         if ($closed) { 
    574             $status = ''; 
    575         } else { 
    576             $status = 'status = 1'; 
    577         } 
    578524        $category_id = (int) $category_id; 
    579525        $product_id = (int) $product_id; 
    580         if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_category','category_id', $category_id)) { 
     526        if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_category','category_id', array($category_id))) { 
    581527            $category_id = array($category_id); 
    582         } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', $product_id, $status)) { 
    583             $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    584             $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); 
    585528        } else { 
    586             // 不正な場合は、空の配列を返す。 
    587             $category_id = array(); 
     529            $objProduct = new SC_Product_Ex(); 
     530            $category_id = $objProduct->getCategoryIds($product_id, $closed); 
    588531        } 
    589532 
Note: See TracChangeset for help on using the changeset viewer.