1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2009 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 | require_once CLASS_PATH . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * こんな商品も買っていますプラグインを制御するクラス |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author Seasoft 塚田将久 |
---|
31 | * @version $Id:$ |
---|
32 | */ |
---|
33 | class LC_Page_FrontParts_Bloc_Recommend extends LC_Page_FrontParts_Bloc { |
---|
34 | |
---|
35 | /** プラグイン情報配列 (呼び出し元でセットする) */ |
---|
36 | var $arrPluginInfo; |
---|
37 | |
---|
38 | /** 取得する上限数 */ |
---|
39 | var $max = 4; |
---|
40 | |
---|
41 | var $arrRecommendProducts = array(); |
---|
42 | |
---|
43 | /** |
---|
44 | * Page を初期化する. |
---|
45 | * |
---|
46 | * @return void |
---|
47 | */ |
---|
48 | function init() { |
---|
49 | parent::init(); |
---|
50 | $this->tpl_mainpage = $this->arrPluginInfo['fullpath'] . 'tpl/bloc.tpl'; |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Page のプロセス. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | function process() { |
---|
59 | $objSubView = new SC_SiteView(false); |
---|
60 | |
---|
61 | $this->arrRecommendProducts = $this->lfGetRecommendProducts($_REQUEST['product_id']); |
---|
62 | |
---|
63 | $objSubView->assignobj($this); |
---|
64 | $objSubView->display($this->tpl_mainpage); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * デストラクタ. |
---|
69 | * |
---|
70 | * @return void |
---|
71 | */ |
---|
72 | function destroy() { |
---|
73 | parent::destroy(); |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * デストラクタ. |
---|
78 | * |
---|
79 | * @return void |
---|
80 | */ |
---|
81 | function lfGetRecommendProducts($product_id) { |
---|
82 | |
---|
83 | $objQuery = new SC_Query(); |
---|
84 | $cols = '*, (SELECT COUNT(*) FROM dtb_order_detail WHERE product_id = alldtl.product_id) AS cnt'; |
---|
85 | $from = 'vw_products_allclass_detail AS alldtl'; |
---|
86 | $where = <<< __EOS__ |
---|
87 | del_flg = 0 |
---|
88 | AND status = 1 |
---|
89 | AND product_id IN ( |
---|
90 | SELECT product_id |
---|
91 | FROM |
---|
92 | dtb_order_detail |
---|
93 | INNER JOIN dtb_order |
---|
94 | ON dtb_order_detail.order_id = dtb_order.order_id |
---|
95 | WHERE 0=0 |
---|
96 | AND dtb_order.del_flg = 0 |
---|
97 | AND dtb_order.order_id IN ( |
---|
98 | SELECT order_id |
---|
99 | FROM dtb_order_detail |
---|
100 | WHERE 0=0 |
---|
101 | AND product_id = ? |
---|
102 | ) |
---|
103 | AND dtb_order_detail.product_id <> ? |
---|
104 | ) |
---|
105 | __EOS__; |
---|
106 | $objQuery->setorder('cnt DESC, RANDOM()'); |
---|
107 | $objQuery->setlimit($this->max); |
---|
108 | $recommendProducts = $objQuery->select($cols, $from, $where, array($product_id, $product_id)); |
---|
109 | |
---|
110 | return $recommendProducts; |
---|
111 | } |
---|
112 | } |
---|
113 | ?> |
---|