source: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php @ 23460

Revision 23460, 27.5 KB checked in by pineray, 10 years ago (diff)

#2515 無駄な処理を改善する for 2.13.3

商品IDのチェックを共通関数化.
チェック部分のエラーを修正.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26if (file_exists(MODULE_REALDIR . 'mdl_gmopg/inc/function.php')) {
27    require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php';
28}
29/**
30 * 商品詳細 のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
35 */
36class LC_Page_Products_Detail extends LC_Page_Ex
37{
38    /** 商品ステータス */
39    public $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    public $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    public $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    public $arrRECOMMEND;
49
50    /** @var SC_FormParam フォームパラメーター */
51    public $objFormParam;
52
53    /** @var SC_UploadFile アップロードファイル */
54    public $objUpFile;
55
56    /** @var string モード */
57    public $mode;
58
59    /** @var array 商品情報 */
60    public $arrProduct;
61
62    /** @var string 規格1クラス名 */
63    public $tpl_class_name1;
64
65    /** @var string 規格2クラス名 */
66    public $tpl_class_name2;
67
68    /** @var bool 在庫があるかどうか */
69    public $tpl_stock_find;
70
71    /** @var array 規格1の規格分類 */
72    public $arrClassCat1;
73
74    /** @var bool 規格1が設定されている */
75    public $tpl_classcat_find1;
76
77    /** @var bool 規格2が設定されている */
78    public $tpl_classcat_find2;
79
80    /** @var int デフォルトの商品規格ID */
81    public $tpl_product_class_id;
82
83    /** @var int デフォルトの商品タイプ */
84    public $tpl_product_type;
85
86    /** @var string ページ表示時に実行するJavaScript */
87    public $js_lnOnload;
88
89    /** @var int 商品ID */
90    public $tpl_product_id;
91
92    /** @var array フォーム情報 */
93    public $arrForm;
94
95    /** @var string サブタイトル */
96    public $tpl_subtitle;
97
98    /** @var array 関連カテゴリー */
99    public $arrRelativeCat;
100
101    /** @var array 商品ステータス(アイコン) */
102    public $productStatus;
103
104    /** @var bool サブ画像が存在するか */
105    public $subImageFlag;
106
107    /** @var array レビュー情報 */
108    public $arrReview;
109
110    /** @var array 関連商品情報 */
111    public $arrRecommend;
112
113    /** @var array ファイル情報 */
114    public $arrFile;
115
116    /** @var bool ログイン状態かどうか */
117    public $tpl_login;
118
119    /** @var bool お気に入りに登録済みか */
120    public $is_favorite;
121
122    /** @var bool お気に入りに登録したことを示すフラグ */
123    public $just_added_favorite;
124
125    /** @var array エラー情報 */
126    public $arrErr;
127
128    /**
129     * Page を初期化する.
130     *
131     * @return void
132     */
133    public function init()
134    {
135        parent::init();
136        $masterData = new SC_DB_MasterData_Ex();
137        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
138        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
139        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
140        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
141
142        // POST に限定する mode
143        $this->arrLimitPostMode[] = 'cart';
144        $this->arrLimitPostMode[] = 'add_favorite';
145        $this->arrLimitPostMode[] = 'add_favorite_sphone';
146        $this->arrLimitPostMode[] = 'select';
147        $this->arrLimitPostMode[] = 'select2';
148        $this->arrLimitPostMode[] = 'selectItem';
149    }
150
151    /**
152     * Page のプロセス.
153     *
154     * @return void
155     */
156    public function process()
157    {
158        parent::process();
159        $this->action();
160        $this->sendResponse();
161    }
162
163    /**
164     * Page のAction.
165     *
166     * @return void
167     */
168    public function action()
169    {
170        //決済処理中ステータスのロールバック
171        $objPurchase = new SC_Helper_Purchase_Ex();
172        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
173
174        // 会員クラス
175        $objCustomer = new SC_Customer_Ex();
176
177        // パラメーター管理クラス
178        $this->objFormParam = new SC_FormParam_Ex();
179        // パラメーター情報の初期化
180        $this->arrForm = $this->lfInitParam($this->objFormParam);
181        // ファイル管理クラス
182        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
183        // ファイル情報の初期化
184        $this->objUpFile = $this->lfInitFile($this->objUpFile);
185        $this->mode = $this->getMode();
186
187        $objProduct = new SC_Product_Ex();
188
189        // プロダクトIDの正当性チェック
190        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'), $objProduct);
191
192        $objProduct->setProductsClassByProductIds(array($product_id));
193
194        // 規格1クラス名
195        $this->tpl_class_name1 = $objProduct->className1[$product_id];
196
197        // 規格2クラス名
198        $this->tpl_class_name2 = $objProduct->className2[$product_id];
199
200        // 規格1
201        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
202
203        // 規格1が設定されている
204        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
205        // 規格2が設定されている
206        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
207
208        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
209        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
210        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
211
212        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
213        if ($this->tpl_stock_find) {
214            // 規格選択セレクトボックスの作成
215            $this->js_lnOnload .= $this->lfMakeSelect();
216        }
217
218        $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
219        $this->tpl_javascript .= 'function lnOnLoad()
220        {' . $this->js_lnOnload . '}';
221        $this->tpl_onload .= 'lnOnLoad();';
222
223        // モバイル用 規格選択セレクトボックスの作成
224        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
225            $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
226        }
227
228        // 商品IDをFORM内に保持する
229        $this->tpl_product_id = $product_id;
230
231        switch ($this->mode) {
232            case 'cart':
233                $this->doCart();
234                break;
235
236            case 'add_favorite':
237                $this->doAddFavorite($objCustomer);
238                break;
239
240            case 'add_favorite_sphone':
241                $this->doAddFavoriteSphone($objCustomer);
242                break;
243
244            case 'select':
245            case 'select2':
246            case 'selectItem':
247                /**
248                 * モバイルの数量指定・規格選択の際に、
249                 * $_SESSION['cart_referer_url'] を上書きさせないために、
250                 * 何もせずbreakする。
251                 */
252                break;
253
254            default:
255                $this->doDefault();
256                break;
257        }
258
259        // モバイル用 ポストバック処理
260        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
261            switch ($this->mode) {
262                case 'select':
263                    $this->doMobileSelect();
264                    break;
265
266                case 'select2':
267                    $this->doMobileSelect2();
268                    break;
269
270                case 'selectItem':
271                    $this->doMobileSelectItem();
272                    break;
273
274                case 'cart':
275                    $this->doMobileCart();
276                    break;
277
278                default:
279                    $this->doMobileDefault();
280                    break;
281            }
282        }
283
284        // 商品詳細を取得
285        $this->arrProduct = $objProduct->getDetail($product_id);
286
287        // サブタイトルを取得
288        $this->tpl_subtitle = $this->arrProduct['name'];
289
290        // 関連カテゴリを取得
291        $arrCategory_id = $objProduct->getCategoryIds($product_id);
292        $objCategory = new SC_Helper_Category_Ex();
293        $this->arrRelativeCat = array();
294        foreach ($arrCategory_id as $category_id) {
295            $this->arrRelativeCat[] = $objCategory->getTreeTrail($category_id, false);
296        }
297
298        // 商品ステータスを取得
299        $this->productStatus = $objProduct->getProductStatus($product_id);
300
301        // 画像ファイル指定がない場合の置換処理
302        $this->arrProduct['main_image']
303            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
304
305        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
306        //レビュー情報の取得
307        $this->arrReview = $this->lfGetReviewData($product_id);
308
309        //関連商品情報表示
310        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
311
312        // ログイン判定
313        if ($objCustomer->isLoginSuccess() === true) {
314            //お気に入りボタン表示
315            $this->tpl_login = true;
316            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
317        }
318    }
319
320    /**
321     * プロダクトIDの正当性チェック
322     *
323     * @param string $admin_mode
324     * @param int $product_id
325     * @param SC_Product $objProduct
326     * @return int|void
327     */
328    public function lfCheckProductId($admin_mode, $product_id, SC_Product $objProduct)
329    {
330        // 管理機能からの確認の場合は、非公開の商品も表示する。
331        if (isset($admin_mode) && $admin_mode == 'on' && SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex(), false)) {
332            $include_hidden = true;
333        } else {
334            $include_hidden = false;
335        }
336
337        if (!$objProduct->isValidProductId($product_id, $include_hidden)) {
338                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
339        }
340
341        return $product_id;
342    }
343
344    /**
345     * ファイル情報の初期化
346     *
347     * @param SC_UploadFile $objUpFile
348     * @return SC_UploadFile
349     */
350    public function lfInitFile(SC_UploadFile $objUpFile)
351    {
352        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
353        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
354            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
355        }
356
357        return $objUpFile;
358    }
359
360    /* 規格選択セレクトボックスの作成 */
361    public function lfMakeSelect()
362    {
363        return 'fnSetClassCategories('
364            . 'document.form1, '
365            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
366            . '); ';
367    }
368
369    /* 規格選択セレクトボックスの作成(モバイル) */
370    public function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1)
371    {
372        $classcat_find1 = false;
373        $classcat_find2 = false;
374
375        // 規格名一覧
376        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
377        // 規格分類名一覧
378        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
379        // 商品規格情報の取得
380        $arrProductsClass = $this->lfGetProductsClass($product_id);
381
382        // 規格1クラス名の取得
383        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
384        // 規格2クラス名の取得
385        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
386
387        // 全ての組み合わせ数
388        $count = count($arrProductsClass);
389
390        $classcat_id1 = '';
391        $classcat_id2 = '';
392
393        $arrSele1 = array();
394        $arrSele2 = array();
395
396        for ($i = 0; $i < $count; $i++) {
397            // 在庫のチェック
398            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
399                continue;
400            }
401
402            // 規格1のセレクトボックス用
403            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
404                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
405                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
406            }
407
408            // 規格2のセレクトボックス用
409            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
410                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
411                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
412            }
413        }
414
415        // 規格1
416        $objPage->arrClassCat1 = $arrSele1;
417        $objPage->arrClassCat2 = $arrSele2;
418
419        // 規格1が設定されている
420        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
421            $classcat_find1 = true;
422        }
423
424        // 規格2が設定されている
425        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
426            $classcat_find2 = true;
427        }
428
429        $objPage->tpl_classcat_find1 = $classcat_find1;
430        $objPage->tpl_classcat_find2 = $classcat_find2;
431    }
432
433    /**
434     * パラメーター情報の初期化
435     *
436     * @param SC_FormParam $objFormParam
437     * @return array
438     */
439    public function lfInitParam(SC_FormParam &$objFormParam)
440    {
441        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
442        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
443        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
444        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK','MAX_LENGTH_CHECK'));
445        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
446        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
447        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
448        // 値の取得
449        $objFormParam->setParam($_REQUEST);
450        // 入力値の変換
451        $objFormParam->convParam();
452        // 入力情報を渡す
453        return $objFormParam->getFormParamList();
454    }
455
456    /* 商品規格情報の取得 */
457    public function lfGetProductsClass($product_id)
458    {
459        $objProduct = new SC_Product_Ex();
460
461        return $objProduct->getProductsClassFullByProductId($product_id);
462    }
463
464    /* 登録済み関連商品の読み込み */
465    public function lfPreGetRecommendProducts($product_id)
466    {
467        $objProduct = new SC_Product_Ex();
468        $objQuery =& SC_Query_Ex::getSingletonInstance();
469
470        $objQuery->setOrder('rank DESC');
471        $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
472
473        $recommendProductIds = array();
474        foreach ($arrRecommendData as $recommend) {
475            $recommendProductIds[] = $recommend['recommend_product_id'];
476        }
477
478        $objQuery =& SC_Query_Ex::getSingletonInstance();
479        $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds);
480
481        foreach ($arrRecommendData as $key => $arrRow) {
482            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
483        }
484
485        return $arrRecommendData;
486    }
487
488    /* 入力内容のチェック */
489    public function lfCheckError($mode, SC_FormParam &$objFormParam, $tpl_classcat_find1 = null , $tpl_classcat_find2 = null)
490    {
491        switch ($mode) {
492        case 'add_favorite_sphone':
493        case 'add_favorite':
494            $objCustomer = new SC_Customer_Ex();
495            $objErr = new SC_CheckError_Ex();
496            $customer_id = $objCustomer->getValue('customer_id');
497            $favorite_product_id = $objCustomer->getValue('favorite_product_id');
498            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
499                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
500            }
501            break;
502        default:
503            // 入力データを渡す。
504            $arrRet =  $objFormParam->getHashArray();
505            $objErr = new SC_CheckError_Ex($arrRet);
506            $objErr->arrErr = $objFormParam->checkError();
507
508            // 複数項目チェック
509            if ($tpl_classcat_find1) {
510                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
511            }
512            if ($tpl_classcat_find2) {
513                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
514            }
515            break;
516        }
517
518        return $objErr->arrErr;
519    }
520
521    /**
522     * 商品ごとのレビュー情報を取得する
523     *
524     * @param int $product_id
525     * @return array
526     */
527    public function lfGetReviewData($product_id)
528    {
529        $objQuery =& SC_Query_Ex::getSingletonInstance();
530        //商品ごとのレビュー情報を取得する
531        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
532        $from = 'dtb_review';
533        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
534        $objQuery->setOrder('create_date DESC');
535        $objQuery->setLimit(REVIEW_REGIST_MAX);
536        $arrWhereVal = array($product_id);
537        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
538
539        return $arrReview;
540    }
541
542    /**
543     * ファイルの情報をセットする
544     *
545     * @param SC_UploadFile $objUpFile
546     * @param array $arrProduct
547     * @param array $arrFile
548     * @return bool
549     */
550    public function lfSetFile(SC_UploadFile $objUpFile, $arrProduct, &$arrFile)
551    {
552        // DBからのデータを引き継ぐ
553        $objUpFile->setDBFileList($arrProduct);
554        // ファイル表示用配列を渡す
555        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
556
557        // サブ画像の有無を判定
558        $subImageFlag = false;
559        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
560            if ($arrFile['sub_image' . $i]['filepath'] != '') {
561                $subImageFlag = true;
562            }
563        }
564
565        return $subImageFlag;
566    }
567
568    /*
569     * お気に入り商品登録
570     * @return void
571     */
572    public function lfRegistFavoriteProduct($favorite_product_id, $customer_id)
573    {
574        // ログイン中のユーザが商品をお気に入りにいれる処理
575        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
576            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
577
578            return false;
579        } else {
580            $objQuery =& SC_Query_Ex::getSingletonInstance();
581            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
582
583            if (!$exists) {
584                $sqlval['customer_id'] = $customer_id;
585                $sqlval['product_id'] = $favorite_product_id;
586                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
587                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
588
589                $objQuery->begin();
590                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
591                $objQuery->commit();
592            }
593            // お気に入りに登録したことを示すフラグ
594            $this->just_added_favorite = true;
595
596            return true;
597        }
598    }
599
600    /**
601     * Add product(s) into the cart.
602     *
603     * @return void
604     */
605    public function doCart()
606    {
607        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
608                                            $this->tpl_classcat_find1,
609                                            $this->tpl_classcat_find2);
610        if (count($this->arrErr) == 0) {
611            $objCartSess = new SC_CartSession_Ex();
612            $product_class_id = $this->objFormParam->getValue('product_class_id');
613
614            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
615
616            // 開いているカテゴリーツリーを維持するためのパラメーター
617            $arrQueryString = array(
618                'product_id' => $this->objFormParam->getValue('product_id'),
619            );
620
621            SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString);
622            SC_Response_Ex::actionExit();
623        }
624    }
625
626    /**
627     * Add product to authenticated user's favorites.
628     *
629     * @param  SC_Customer $objCustomer
630     * @return void
631     */
632    public function doAddFavorite(SC_Customer &$objCustomer)
633    {
634        // ログイン中のユーザが商品をお気に入りにいれる処理
635        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
636            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
637            if (count($this->arrErr) == 0) {
638                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
639                    SC_Response_Ex::actionExit();
640                }
641                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
642                $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
643            }
644        }
645    }
646
647    /**
648     * Add product to authenticated user's favorites. (for Smart phone)
649     *
650     * @param  SC_Customer $objCustomer
651     * @return void
652     */
653    public function doAddFavoriteSphone(SC_Customer $objCustomer)
654    {
655        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
656        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
657            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
658            if (count($this->arrErr) == 0) {
659                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
660                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
661                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
662                    print 'true';
663                    SC_Response_Ex::actionExit();
664                }
665            }
666            print 'error';
667            SC_Response_Ex::actionExit();
668        }
669    }
670
671    /**
672     *
673     *
674     * @return void
675     */
676    public function doDefault()
677    {
678        // カート「戻るボタン」用に保持
679        $netURL = new Net_URL();
680        $_SESSION['cart_referer_url'] = $netURL->getURL();
681    }
682
683    /**
684     *
685     * @return void
686     */
687    public function doMobileSelect()
688    {
689        // 規格1が設定されている場合
690        if ($this->tpl_classcat_find1) {
691            // templateの変更
692            $this->tpl_mainpage = 'products/select_find1.tpl';
693
694            return;
695        }
696
697        // 数量の入力を行う
698        $this->tpl_mainpage = 'products/select_item.tpl';
699    }
700
701    /**
702     *
703     * @return void
704     */
705    public function doMobileSelect2()
706    {
707        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
708
709        // 規格1が設定されていて、エラーを検出した場合
710        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
711            // templateの変更
712            $this->tpl_mainpage = 'products/select_find1.tpl';
713
714            return;
715        }
716
717        // 規格2が設定されている場合
718        if ($this->tpl_classcat_find2) {
719            $this->arrErr = array();
720
721            $this->tpl_mainpage = 'products/select_find2.tpl';
722
723            return;
724        }
725
726        $this->doMobileSelectItem();
727    }
728
729    /**
730     *
731     * @return void
732     */
733    public function doMobileSelectItem()
734    {
735        $objProduct = new SC_Product_Ex();
736
737        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
738
739        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
740        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
741        unset($this->arrErr['product_class_id']);
742        unset($this->arrErr['quantity']);
743
744        // 規格2が設定されていて、エラーを検出した場合
745        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
746            // templateの変更
747            $this->tpl_mainpage = 'products/select_find2.tpl';
748
749            return;
750        }
751
752        $product_id = $this->objFormParam->getValue('product_id');
753
754        $value1 = $this->objFormParam->getValue('classcategory_id1');
755        if (strlen($value1) === 0) {
756            $value1 = '__unselected';
757        }
758
759        // 規格2が設定されている場合.
760        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
761            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
762        } else {
763            $value2 = '#0';
764        }
765
766        $objProduct->setProductsClassByProductIds(array($product_id));
767        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
768
769        // 数量の入力を行う
770        $this->tpl_mainpage = 'products/select_item.tpl';
771    }
772
773    /**
774     *
775     * @return void
776     */
777    public function doMobileCart()
778    {
779        // この段階でエラーが出る場合は、数量の入力エラーのはず
780        if (count($this->arrErr)) {
781            // 数量の入力を行う
782            $this->tpl_mainpage = 'products/select_item.tpl';
783        }
784    }
785
786    /**
787     *
788     * @return void
789     */
790    public function doMobileDefault()
791    {
792        $this->tpl_mainpage = 'products/detail.tpl';
793    }
794}
Note: See TracBrowser for help on using the repository browser.