1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * RSS(商品) のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Rss_Products extends LC_Page { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_mainpage = "rss/product.tpl"; |
---|
47 | $this->encode = "UTF-8"; |
---|
48 | $this->title = "商品一覧情報"; |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * Page のプロセス. |
---|
53 | * |
---|
54 | * @return void |
---|
55 | */ |
---|
56 | function process() { |
---|
57 | $objQuery = new SC_Query(); |
---|
58 | $objView = new SC_SiteView(); |
---|
59 | $objSiteInfo = new SC_SiteInfo(); |
---|
60 | |
---|
61 | //店舗情報をセット |
---|
62 | $this->arrSiteInfo = $objSiteInfo->data; |
---|
63 | |
---|
64 | //商品IDを取得 |
---|
65 | $product_id = $_GET['product_id']; |
---|
66 | $mode = $_GET['mode']; |
---|
67 | |
---|
68 | if(($product_id != "" and is_numeric($product_id)) or $mode == "all"){ |
---|
69 | //商品詳細を取得 |
---|
70 | ($mode == "all") ? $arrProduct = $this->lfGetProductsDetail($objQuery, $mode) : $arrProduct = $this->lfGetProductsDetail($objQuery, $product_id); |
---|
71 | |
---|
72 | // 値のセットし直し |
---|
73 | foreach($arrProduct as $key => $val){ |
---|
74 | //販売価格を税込みに編集 |
---|
75 | $arrProduct[$key]["price02"] = SC_Helper_DB_Ex::sfPreTax($arrProduct[$key]["price02"]); |
---|
76 | |
---|
77 | // 画像ファイルのURLセット |
---|
78 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
79 | $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; |
---|
80 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
81 | $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; |
---|
82 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
83 | $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; |
---|
84 | |
---|
85 | // ポイント計算 |
---|
86 | $arrProduct[$key]["point"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); |
---|
87 | |
---|
88 | // 在庫無制限 |
---|
89 | $arrProduct[$key]["stock_unlimited"] = ($arrProduct[$key]["stock_unlimited"] == 1) ? "在庫無制限" : NULL; |
---|
90 | } |
---|
91 | }elseif($mode == "list"){ |
---|
92 | //商品一覧を取得 |
---|
93 | $arrProduct = $objQuery->getall("SELECT product_id, name AS product_name FROM dtb_products"); |
---|
94 | }else{ |
---|
95 | $arrProduct = $this->lfGetProductsAllclass($objQuery); |
---|
96 | |
---|
97 | // 値のセットし直し |
---|
98 | foreach($arrProduct as $key => $val){ |
---|
99 | //販売価格を税込みに編集 |
---|
100 | $arrProduct[$key]["price02_max"] = SC_Helper_DB_Ex::sfPreTax($arrProduct[$key]["price02_max"]); |
---|
101 | $arrProduct[$key]["price02_min"] = SC_Helper_DB_Ex::sfPreTax($arrProduct[$key]["price02_min"]); |
---|
102 | |
---|
103 | // 画像ファイルのURLセット |
---|
104 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
105 | $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; |
---|
106 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
107 | $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; |
---|
108 | (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; |
---|
109 | $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; |
---|
110 | |
---|
111 | // ポイント計算 |
---|
112 | $arrProduct[$key]["point_max"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_max"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); |
---|
113 | $arrProduct[$key]["point_min"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_min"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | //商品情報をセット |
---|
118 | $this->arrProduct = $arrProduct; |
---|
119 | if(is_array(SC_Utils_Ex::sfswaparray($arrProduct))){ |
---|
120 | $this->arrProductKeys = array_keys(SC_Utils_Ex::sfswaparray($arrProduct)); |
---|
121 | } |
---|
122 | |
---|
123 | //セットしたデータをテンプレートファイルに出力 |
---|
124 | $objView->assignobj($this); |
---|
125 | |
---|
126 | //キャッシュしない(念のため) |
---|
127 | header("Pragma: no-cache"); |
---|
128 | |
---|
129 | //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため) |
---|
130 | header("Content-type: application/xml"); |
---|
131 | DETAIL_P_HTML; |
---|
132 | |
---|
133 | //画面表示 |
---|
134 | $objView->display($this->tpl_mainpage, true); |
---|
135 | } |
---|
136 | |
---|
137 | /** |
---|
138 | * デストラクタ. |
---|
139 | * |
---|
140 | * @return void |
---|
141 | */ |
---|
142 | function destroy() { |
---|
143 | parent::destroy(); |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * 商品情報を取得する |
---|
148 | * |
---|
149 | * @param SC_Query $objQuery DB操作クラス |
---|
150 | * @param integer $product_id 商品ID |
---|
151 | * @return array $arrProduct 取得結果を配列で返す |
---|
152 | */ |
---|
153 | function lfGetProductsDetail(&$objQuery, $product_id = "all"){ |
---|
154 | $sql = ""; |
---|
155 | $sql .= "SELECT "; |
---|
156 | $sql .= " prod.product_id "; |
---|
157 | $sql .= " ,prod.name AS product_name "; |
---|
158 | $sql .= " ,prod.category_id "; |
---|
159 | $sql .= " ,prod.point_rate "; |
---|
160 | $sql .= " ,prod.comment3 "; |
---|
161 | $sql .= " ,prod.main_list_comment "; |
---|
162 | $sql .= " ,prod.main_list_image "; |
---|
163 | $sql .= " ,prod.main_comment "; |
---|
164 | $sql .= " ,prod.main_image "; |
---|
165 | $sql .= " ,prod.main_large_image "; |
---|
166 | $sql .= " ,cls.product_code "; |
---|
167 | $sql .= " ,cls.price01 "; |
---|
168 | $sql .= " ,cls.price02 "; |
---|
169 | $sql .= " ,cls.stock "; |
---|
170 | $sql .= " ,cls.stock_unlimited "; |
---|
171 | $sql .= " ,cls.classcategory_id1 "; |
---|
172 | $sql .= " ,cls.classcategory_id2 "; |
---|
173 | $sql .= " ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id1) AS classcategory_name1 "; |
---|
174 | $sql .= " ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id2) AS classcategory_name2 "; |
---|
175 | $sql .= " ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = prod.category_id) AS category_name"; |
---|
176 | $sql .= " ,prod.update_date "; |
---|
177 | $sql .= " FROM dtb_products AS prod, dtb_products_class AS cls"; |
---|
178 | $sql .= " WHERE prod.product_id = cls.product_id AND prod.del_flg = 0 AND prod.status = 1"; |
---|
179 | |
---|
180 | if($product_id != "all"){ |
---|
181 | $sql .= " AND prod.product_id = ?"; |
---|
182 | $arrval = array($product_id); |
---|
183 | } |
---|
184 | $sql .= " ORDER BY prod.product_id, cls.classcategory_id1, cls.classcategory_id2"; |
---|
185 | $arrProduct = $objQuery->getall($sql, $arrval); |
---|
186 | return $arrProduct; |
---|
187 | } |
---|
188 | |
---|
189 | /** |
---|
190 | * 商品情報を取得する(vw_products_allclass使用) |
---|
191 | * |
---|
192 | * @param SC_Query $objQuery DB操作クラス |
---|
193 | * @return array $arrProduct 取得結果を配列で返す |
---|
194 | */ |
---|
195 | function lfGetProductsAllclass($objQuery){ |
---|
196 | $sql = ""; |
---|
197 | $sql .= "SELECT |
---|
198 | product_id |
---|
199 | ,name as product_name |
---|
200 | ,category_id |
---|
201 | ,point_rate |
---|
202 | ,comment3 |
---|
203 | ,main_list_comment |
---|
204 | ,main_image |
---|
205 | ,main_list_image |
---|
206 | ,product_code_min |
---|
207 | ,product_code_max |
---|
208 | ,price01_min |
---|
209 | ,price01_max |
---|
210 | ,price02_min |
---|
211 | ,price02_max |
---|
212 | ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = allcls.category_id) AS category_name |
---|
213 | ,(SELECT main_large_image FROM dtb_products AS prod WHERE prod.product_id = allcls.product_id) AS main_large_image |
---|
214 | FROM vw_products_allclass as allcls |
---|
215 | WHERE allcls.del_flg = 0 AND allcls.status = 1"; |
---|
216 | |
---|
217 | // 在庫無し商品の非表示 |
---|
218 | if (NOSTOCK_HIDDEN === true) { |
---|
219 | $sql .= ' AND (allcls.stock_max >= 1 OR allcls.stock_unlimited_max = 1)'; |
---|
220 | } |
---|
221 | |
---|
222 | $sql .= " ORDER BY allcls.product_id"; |
---|
223 | |
---|
224 | $arrProduct = $objQuery->getall($sql); |
---|
225 | return $arrProduct; |
---|
226 | } |
---|
227 | } |
---|
228 | ?> |
---|