1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * Recommend のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id: LC_Page_FrontParts_Bloc_Best5 - Copy.php -1 $ |
---|
33 | */ |
---|
34 | class LC_Page_FrontParts_Bloc_Recommend extends LC_Page_FrontParts_Bloc { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->setTplMainpage('recommend.tpl'); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * Page のプロセス. |
---|
51 | * |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | function process() { |
---|
55 | $this->action(); |
---|
56 | $this->sendResponse(); |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Page のアクション. |
---|
61 | * |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | function action() { |
---|
65 | |
---|
66 | // 基本情報を渡す |
---|
67 | $objSiteInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
68 | $this->arrInfo = $objSiteInfo->data; |
---|
69 | |
---|
70 | //おすすめ商品表示 |
---|
71 | $this->arrBestProducts = $this->lfGetRanking(); |
---|
72 | } |
---|
73 | |
---|
74 | /** |
---|
75 | * デストラクタ. |
---|
76 | * |
---|
77 | * @return void |
---|
78 | */ |
---|
79 | function destroy() { |
---|
80 | parent::destroy(); |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * おすすめ商品検索. |
---|
85 | * |
---|
86 | * @return array $arrBestProducts 検索結果配列 |
---|
87 | */ |
---|
88 | function lfGetRanking(){ |
---|
89 | $arrProduct = array(); |
---|
90 | // おすすめ商品取得 |
---|
91 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
92 | |
---|
93 | $col = 'best_id, best_id, category_id, rank, product_id, title, comment, create_date, update_date'; |
---|
94 | $table = 'dtb_best_products'; |
---|
95 | $where = 'del_flg = 0'; |
---|
96 | $objQuery->setOrder('rank'); |
---|
97 | $objQuery->setLimit(RECOMMEND_NUM); |
---|
98 | $arrBestProducts = $objQuery->select($col, $table, $where); |
---|
99 | if ( is_array($arrBestProducts) && count($arrBestProducts) > 0 ) { |
---|
100 | // 各商品の詳細情報を取得 |
---|
101 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
102 | $objProduct = new SC_Product_Ex(); |
---|
103 | // where条件生成&セット |
---|
104 | $arrBestProductIds = array(); |
---|
105 | $where = 'product_id IN ( '; |
---|
106 | foreach( $arrBestProducts as $key => $val ) { |
---|
107 | $arrBestProductIds[] = $val['product_id']; |
---|
108 | } |
---|
109 | $where .= implode(', ', $arrBestProductIds); |
---|
110 | $where .= ' )'; |
---|
111 | $objQuery->setWhere($where); |
---|
112 | // 取得 |
---|
113 | $arrProductList = $objProduct->lists($objQuery); |
---|
114 | // おすすめ商品情報とマージ |
---|
115 | foreach( $arrProductList as $pdct_key => $pdct_val ) { |
---|
116 | foreach( $arrBestProducts as $best_key => $best_val ) { |
---|
117 | if ( $pdct_val['product_id'] == $best_val['product_id'] ) { |
---|
118 | $arrProduct[$best_key] = array_merge($best_val, $pdct_val); |
---|
119 | break; |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | return $arrProduct; |
---|
125 | } |
---|
126 | } |
---|
127 | ?> |
---|