Changeset 23653


Ignore:
Timestamp:
2014/10/14 10:59:22 (9 years ago)
Author:
kim
Message:

#2515 r23458 をリバート

既存の関数の削除が行われている部分を差し戻す。
SC_Product.phpの拡張自体は有効とする。

Location:
branches/version-2_13_3/data/class
Files:
2 edited

Legend:

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

    r23606 r23653  
    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    /** 
    373423     * 親カテゴリを連結した文字列を取得する. 
    374424     * 
     
    514564     * 選択中の商品のカテゴリを取得する. 
    515565     * 
    516      * @param   int $product_id     プロダクトID 
    517      * @param   int $category_id    カテゴリID 
     566     * @param  integer $product_id  プロダクトID 
     567     * @param  integer $category_id カテゴリID 
    518568     * @param   bool $closed        非表示の商品を含む場合はtrue 
    519      * @return  array   選択中の商品のカテゴリIDの配列 
     569     * @return array   選択中の商品のカテゴリIDの配列 
    520570     * 
    521571     */ 
    522572    public function sfGetCategoryId($product_id, $category_id = 0, $closed = false) 
    523573    { 
     574        if ($closed) { 
     575            $status = ''; 
     576        } else { 
     577            $status = 'status = 1'; 
     578        } 
    524579        $category_id = (int) $category_id; 
    525580        $product_id = (int) $product_id; 
     
    527582        if ($objCategory->isValidCategoryId($category_id, $closed)) { 
    528583            $category_id = array($category_id); 
     584        } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', $product_id, $status)) { 
     585            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     586            $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); 
    529587        } else { 
    530             $objProduct = new SC_Product_Ex(); 
    531             $category_id = $objProduct->getCategoryIds($product_id, $closed); 
     588            // 不正な場合は、空の配列を返す。 
     589            $category_id = array(); 
    532590        } 
    533591 
  • branches/version-2_13_3/data/class/pages/products/LC_Page_Products_Detail.php

    r23606 r23653  
    289289 
    290290        // 関連カテゴリを取得 
    291         $arrCategory_id = $objProduct->getCategoryIds($product_id); 
    292         $objCategory = new SC_Helper_Category_Ex(); 
    293         $this->arrRelativeCat = array(); 
    294         foreach ($arrCategory_id as $category_id) { 
    295             $this->arrRelativeCat[] = $objCategory->getTreeTrail($category_id, false); 
    296         } 
     291        $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); 
    297292 
    298293        // 商品ステータスを取得 
Note: See TracChangeset for help on using the changeset viewer.