source: branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php @ 20487

Revision 20487, 4.0 KB checked in by shutta, 13 years ago (diff)

SC_Productクラスのclass_extends対応

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 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
25require_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 */
34class 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::getSingletonInstance();
92        $sql = '';
93        $sql .= ' SELECT';
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        if ( is_array($arrBestProducts) && count($arrBestProducts) > 0 ) {
110            // 各商品の詳細情報を取得
111            $objQuery = SC_Query::getSingletonInstance();
112            $objProduct = new SC_Product_Ex();
113            // where条件生成&セット
114            $arrBestProductIds = array();
115            $where = 'product_id IN ( ';
116            foreach( $arrBestProducts as $key => $val ) {
117                $arrBestProductIds[] = $val['product_id'];
118            }
119            $where .= implode(', ', $arrBestProductIds);
120            $where .= ' )';
121            $objQuery->setWhere($where);
122            // 取得
123            $arrProductList = $objProduct->lists($objQuery);
124            // おすすめ商品情報とマージ
125            foreach( $arrProductList as $pdct_key => $pdct_val ) {
126                foreach( $arrBestProducts as $best_key => $best_val ) {
127                    if ( $pdct_val['product_id'] == $best_val['product_id'] ) {
128                        $arrProduct[$best_key] = array_merge($best_val, $pdct_val);
129                        break;
130                    }
131                }
132            }
133        }
134        return $arrProduct;
135    }
136}
137?>
Note: See TracBrowser for help on using the repository browser.