Changeset 20169


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

リファクタリング

Location:
branches/version-2_5-dev/data/class/pages
Files:
2 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} 
  • branches/version-2_5-dev/data/class/pages/rss/LC_Page_Rss_Products.php

    r20116 r20169  
    251251     */ 
    252252    function lfGetProductsDetail(&$objQuery, $product_id = 'all'){ 
    253         $sql = ''; 
    254         $sql .= 'SELECT '; 
    255         $sql .= '   prod.product_id '; 
    256         $sql .= '   ,prod.name AS product_name '; 
    257         $sql .= '   ,prod.category_id '; 
    258         $sql .= '   ,prod.point_rate '; 
    259         $sql .= '   ,prod.comment3 '; 
    260         $sql .= '   ,prod.main_list_comment '; 
    261         $sql .= '   ,prod.main_list_image '; 
    262         $sql .= '   ,prod.main_comment '; 
    263         $sql .= '   ,prod.main_image '; 
    264         $sql .= '   ,prod.main_large_image '; 
    265         $sql .= '   ,cls.product_code '; 
    266         $sql .= '   ,cls.price01 '; 
    267         $sql .= '   ,cls.price02 '; 
    268         $sql .= '   ,cls.stock '; 
    269         $sql .= '   ,cls.stock_unlimited '; 
    270         $sql .= '   ,cls.classcategory_id1 '; 
    271         $sql .= '   ,cls.classcategory_id2 '; 
    272         $sql .= '   ,( '; 
    273         $sql .= '     SELECT '; 
    274         $sql .= '        name '; 
    275         $sql .= '     FROM '; 
    276         $sql .= '        dtb_classcategory AS clscat '; 
    277         $sql .= '     WHERE '; 
    278         $sql .= '        clscat.classcategory_id = cls.classcategory_id1 '; 
    279         $sql .= '   ) AS classcategory_name1 '; 
    280         $sql .= '   ,( '; 
    281         $sql .= '     SELECT '; 
    282         $sql .= '        name '; 
    283         $sql .= '     FROM '; 
    284         $sql .= '        dtb_classcategory AS clscat '; 
    285         $sql .= '     WHERE '; 
    286         $sql .= '        clscat.classcategory_id = cls.classcategory_id2 '; 
    287         $sql .= '   ) AS classcategory_name2 '; 
    288         $sql .= '   ,( '; 
    289         $sql .= '     SELECT '; 
    290         $sql .= '        category_name '; 
    291         $sql .= '     FROM '; 
    292         $sql .= '        dtb_category AS cat '; 
    293         $sql .= '     WHERE '; 
    294         $sql .= '        cat.category_id = prod.category_id '; 
    295         $sql .= '   ) AS category_name '; 
    296         $sql .= '   ,prod.update_date '; 
    297         $sql .= ' FROM dtb_products AS prod, dtb_products_class AS cls'; 
    298         $sql .= ' WHERE prod.product_id = cls.product_id AND prod.del_flg = 0 AND prod.status = 1'; 
    299  
    300         if($product_id != 'all'){ 
    301             $sql .= ' AND prod.product_id = ?'; 
    302             $arrval = array($product_id); 
    303         } 
    304         $sql .= ' ORDER BY prod.product_id, cls.classcategory_id1, cls.classcategory_id2'; 
    305         $arrProduct = $objQuery->getAll($sql, $arrval); 
     253        // --- 商品詳細の取得 
     254        if ($product_id != 'all') { 
     255            $where = 'product_id = ' . $product_id; 
     256            $objQuery->setWhere($where); 
     257        } 
     258        $objQuery->setOrder('product_id'); 
     259        $objProduct = new SC_Product(); 
     260        $arrProductLsit = $objProduct->lists($objQuery); 
     261        // 各商品のカテゴリIDとランクの取得 
     262        $arrProduct = array(); 
     263        foreach( $arrProductLsit as $key => $val ) { 
     264            $sql = ''; 
     265            $sql .= ' SELECT'; 
     266            $sql .= '   T1.category_id,'; 
     267            $sql .= '   T1.rank AS product_rank,'; 
     268            $sql .= '   T2.rank AS category_rank'; 
     269            $sql .= ' FROM'; 
     270            $sql .= '   dtb_product_categories AS T1'; 
     271            $sql .= ' LEFT JOIN'; 
     272            $sql .= '   dtb_category AS T2'; 
     273            $sql .= ' ON'; 
     274            $sql .= '   T1.category_id = T2.category_id'; 
     275            $sql .= ' WHERE'; 
     276            $sql .= '   product_id = ?'; 
     277            $arrCategory = $objQuery->getAll($sql, array($val['product_id'])); 
     278            if ( !empty($arrCategory) ) { 
     279                $arrProduct[$key] = array_merge($val, $arrCategory[0]); 
     280            } 
     281        } 
    306282        return $arrProduct; 
    307283    } 
     
    314290     */ 
    315291    function lfGetProductsAllclass(&$objQuery){ 
    316         $sql = ''; 
    317         $sql .= ' SELECT'; 
    318         $sql .= '     T1.product_id,'; 
    319         $sql .= '     T1.name as product_name,'; 
    320         $sql .= '     T1.maker_id,'; 
    321         $sql .= '     T1.status,'; 
    322         $sql .= '     T1.comment1,'; 
    323         $sql .= '     T1.comment2,'; 
    324         $sql .= '     T1.comment3,'; 
    325         $sql .= '     T1.comment4,'; 
    326         $sql .= '     T1.comment5,'; 
    327         $sql .= '     T1.comment6,'; 
    328         $sql .= '     T1.note,'; 
    329         $sql .= '     T1.main_list_comment,'; 
    330         $sql .= '     T1.main_list_image,'; 
    331         $sql .= '     T1.main_comment,'; 
    332         $sql .= '     T1.main_image,'; 
    333         $sql .= '     T1.main_large_image,'; 
    334         $sql .= '     T1.sub_title1,'; 
    335         $sql .= '     T1.sub_comment1,'; 
    336         $sql .= '     T1.sub_image1,'; 
    337         $sql .= '     T1.sub_large_image1,'; 
    338         $sql .= '     T1.sub_title2,'; 
    339         $sql .= '     T1.sub_comment2,'; 
    340         $sql .= '     T1.sub_image2,'; 
    341         $sql .= '     T1.sub_large_image2,'; 
    342         $sql .= '     T1.sub_title3,'; 
    343         $sql .= '     T1.sub_comment3,'; 
    344         $sql .= '     T1.sub_image3,'; 
    345         $sql .= '     T1.sub_large_image3,'; 
    346         $sql .= '     T1.sub_title4,'; 
    347         $sql .= '     T1.sub_comment4,'; 
    348         $sql .= '     T1.sub_image4,'; 
    349         $sql .= '     T1.sub_large_image4,'; 
    350         $sql .= '     T1.sub_title5,'; 
    351         $sql .= '     T1.sub_comment5,'; 
    352         $sql .= '     T1.sub_image5,'; 
    353         $sql .= '     T1.sub_large_image5,'; 
    354         $sql .= '     T1.sub_title6,'; 
    355         $sql .= '     T1.sub_comment6,'; 
    356         $sql .= '     T1.sub_image6,'; 
    357         $sql .= '     T1.sub_large_image6,'; 
    358         $sql .= '     T1.del_flg,'; 
    359         $sql .= '     T1.creator_id,'; 
    360         $sql .= '     T1.create_date,'; 
    361         $sql .= '     T1.update_date,'; 
    362         $sql .= '     T1.deliv_date_id,'; 
    363         $sql .= '     T4.product_code_min,'; 
    364         $sql .= '     T4.product_code_max,'; 
    365         $sql .= '     T4.price01_min,'; 
    366         $sql .= '     T4.price01_max,'; 
    367         $sql .= '     T4.price02_min,'; 
    368         $sql .= '     T4.price02_max,'; 
    369         $sql .= '     T4.stock_min,'; 
    370         $sql .= '     T4.stock_max,'; 
    371         $sql .= '     T4.stock_unlimited_min,'; 
    372         $sql .= '     T4.stock_unlimited_max,'; 
    373         $sql .= '     T4.class_count,'; 
    374         $sql .= '     T3.rank AS category_rank,'; 
    375         $sql .= '     T2.category_id,'; 
    376         $sql .= '     T2.rank AS product_rank'; 
    377         $sql .= ' FROM'; 
    378         $sql .= '     dtb_products AS T1'; 
    379         $sql .= '     LEFT JOIN'; 
    380         $sql .= '         ('; 
    381         $sql .= '             SELECT'; 
    382         $sql .= '                 product_id,'; 
    383         $sql .= '                 MIN(product_code) AS product_code_min,'; 
    384         $sql .= '                 MAX(product_code) AS product_code_max,'; 
    385         $sql .= '                 MIN(price01) AS price01_min,'; 
    386         $sql .= '                 MAX(price01) AS price01_max,'; 
    387         $sql .= '                 MIN(price02) AS price02_min,'; 
    388         $sql .= '                 MAX(price02) AS price02_max,'; 
    389         $sql .= '                 MIN(stock) AS stock_min,'; 
    390         $sql .= '                 MAX(stock) AS stock_max,'; 
    391         $sql .= '                 MIN(stock_unlimited) AS stock_unlimited_min,'; 
    392         $sql .= '                 MAX(stock_unlimited) AS stock_unlimited_max,'; 
    393         $sql .= '                 COUNT(*) as class_count'; 
    394         $sql .= '             FROM'; 
    395         $sql .= '                 dtb_products_class'; 
    396         $sql .= '             GROUP BY'; 
    397         $sql .= '                 product_id'; 
    398         $sql .= '         ) AS T4'; 
    399         $sql .= '     ON'; 
    400         $sql .= '         T1.product_id = T4.product_id'; 
    401         $sql .= '     LEFT JOIN'; 
    402         $sql .= '         dtb_product_categories AS T2'; 
    403         $sql .= '     ON'; 
    404         $sql .= '         T1.product_id = T2.product_id'; 
    405         $sql .= '     LEFT JOIN'; 
    406         $sql .= '         dtb_category AS T3'; 
    407         $sql .= '     ON'; 
    408         $sql .= '         T2.category_id = T3.category_id'; 
    409         $sql .= ' WHERE'; 
    410         $sql .= '     T1.del_flg = 0 AND T1.status = 1 '; 
    411          
    412         // 在庫無し商品の非表示 
    413         if (NOSTOCK_HIDDEN === true) { 
    414             $sql .= ' AND (T4.stock_max >= 1 OR T4.stock_unlimited_max = 1)'; 
    415         } 
    416          
    417         $sql .= ' ORDER BY'; 
    418         $sql .= '     T1.product_id asc'; 
    419          
    420         $arrProduct = $objQuery->getAll($sql); 
    421         return $arrProduct; 
    422          
     292        // --- 商品一覧の取得 
     293        $objQuery->setOrder('product_id'); 
     294        $objProduct = new SC_Product(); 
     295        $arrProductLsit = $objProduct->lists($objQuery); 
     296        // 各商品のカテゴリIDとランクの取得 
     297        $arrProduct = array(); 
     298        foreach( $arrProductLsit as $key => $val ) { 
     299            $sql = ''; 
     300            $sql .= ' SELECT'; 
     301            $sql .= '   T1.category_id,'; 
     302            $sql .= '   T1.rank AS product_rank,'; 
     303            $sql .= '   T2.rank AS category_rank'; 
     304            $sql .= ' FROM'; 
     305            $sql .= '   dtb_product_categories AS T1'; 
     306            $sql .= ' LEFT JOIN'; 
     307            $sql .= '   dtb_category AS T2'; 
     308            $sql .= ' ON'; 
     309            $sql .= '   T1.category_id = T2.category_id'; 
     310            $sql .= ' WHERE'; 
     311            $sql .= '   product_id = ?'; 
     312            $arrCategory = $objQuery->getAll($sql, array($val['product_id'])); 
     313            if ( !empty($arrCategory) ) { 
     314                $arrProduct[$key] = array_merge($val, $arrCategory[0]); 
     315            } 
     316        } 
     317        return $arrProduct; 
    423318    } 
    424319 
Note: See TracChangeset for help on using the changeset viewer.