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

Revision 20116, 23.5 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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-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/LC_Page.php");
26
27if (file_exists(MODULE_REALDIR . "mdl_gmopg/inc/function.php")) {
28    require_once(MODULE_REALDIR . "mdl_gmopg/inc/function.php");
29}
30/**
31 * 商品詳細 のページクラス.
32 *
33 * @package Page
34 * @author LOCKON CO.,LTD.
35 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
36 */
37class LC_Page_Products_Detail extends LC_Page {
38
39    /** ステータス */
40    var $arrSTATUS;
41
42    /** ステータス画像 */
43    var $arrSTATUS_IMAGE;
44
45    /** 発送予定日 */
46    var $arrDELIVERYDATE;
47
48    /** おすすめレベル */
49    var $arrRECOMMEND;
50
51    /** フォームパラメータ */
52    var $objFormParam;
53
54    /** アップロードファイル */
55    var $objUpFile;
56
57    // }}}
58    // {{{ functions
59
60    /**
61     * Page を初期化する.
62     *
63     * @return void
64     */
65    function init() {
66        parent::init();
67        $masterData = new SC_DB_MasterData_Ex();
68        $this->arrSTATUS = $masterData->getMasterData("mtb_status");
69        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
70        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
71        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
72    }
73
74    /**
75     * Page のプロセス.
76     *
77     * @return void
78     */
79    function process() {
80        parent::process();
81        $this->action();
82        $this->sendResponse();
83    }
84
85    /**
86     * Page のAction.
87     *
88     * @return void
89     */
90    function action() {
91        // プロダクトIDの正当性チェック
92        $product_id = $this->lfCheckProductId();
93        $mode = $this->getMode();
94        // XXX 削除可能か、SC_SiteViewクラスコンストラクタ内の処理を要確認
95        $objView = new SC_SiteView(strlen($mode) == 0);
96
97        $objCustomer = new SC_Customer();
98        $objDb = new SC_Helper_DB_Ex();
99
100        // ログイン中のユーザが商品をお気に入りにいれる処理
101        if ($objCustomer->isLoginSuccess() === true && strlen($mode) > 0 && $mode == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) {
102            // 値の正当性チェック
103            if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
104                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
105                exit;
106            } else {
107                $this->arrErr = $this->lfCheckError();
108                if(count($this->arrErr) == 0) {
109                    $customer_id = $objCustomer->getValue('customer_id');
110                    $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);
111                }
112            }
113        }
114
115        // パラメータ管理クラス
116        $this->objFormParam = new SC_FormParam();
117        // パラメータ情報の初期化
118        $this->lfInitParam();
119        // POST値の取得
120        $this->objFormParam->setParam($_POST);
121
122        // ファイル管理クラス
123        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
124        // ファイル情報の初期化
125        $this->lfInitFile();
126
127        // ログイン判定
128        if ($objCustomer->isLoginSuccess() === true) {
129            //お気に入りボタン表示
130            $this->tpl_login = true;
131        }
132
133        // 規格選択セレクトボックスの作成
134        $this->lfMakeSelect($product_id);
135
136        $objProduct = new SC_Product();
137        $objProduct->setProductsClassByProductIds(array($product_id));
138
139        // 規格1クラス名
140        $this->tpl_class_name1 = $objProduct->className1[$product_id];
141
142        // 規格2クラス名
143        $this->tpl_class_name2 = $objProduct->className2[$product_id];
144
145        // 規格1
146        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
147
148        // 規格1が設定されている
149        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
150        // 規格2が設定されている
151        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
152
153        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
154        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id'];
155        $this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type'];
156
157        $objJson = new Services_JSON();
158        $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';';
159        $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}';
160        $this->tpl_onload .= 'lnOnLoad();';
161
162        // モバイル用 規格選択セレクトボックスの作成
163        if(Net_UserAgent_Mobile::isMobile() === true) {
164            $this->lfMakeSelectMobile($this, $product_id);
165        }
166
167        // 商品IDをFORM内に保持する
168        $this->tpl_product_id = $product_id;
169
170        switch($mode) {
171            case 'cart':
172                // 入力値の変換
173                $this->objFormParam->convParam();
174                $this->arrErr = $this->lfCheckError();
175                if (count($this->arrErr) == 0) {
176                    $objCartSess = new SC_CartSession();
177                    $classcategory_id1 = $_POST['classcategory_id1'];
178                    $classcategory_id2 = $_POST['classcategory_id2'];
179                    $product_class_id = $_POST['product_class_id'];
180                    $product_type = $_POST['product_type'];
181
182                    if (!empty($_POST['gmo_oneclick'])) {
183                        $objCartSess->delAllProducts();
184                    }
185
186                    // 規格1が設定されていない場合
187                    if(!$this->tpl_classcat_find1) {
188                        $classcategory_id1 = '0';
189                    }
190
191                    // 規格2が設定されていない場合
192                    if(!$this->tpl_classcat_find2) {
193                        $classcategory_id2 = '0';
194                    }
195                    $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'), $product_type);
196
197                    // カート「戻るボタン」用に保持
198                    if (SC_Utils_Ex::sfIsInternalDomain($_SERVER['HTTP_REFERER'])) {
199                        $_SESSION['cart_referer_url'] = $_SERVER['HTTP_REFERER'];
200                    }
201
202                    if (!empty($_POST['gmo_oneclick'])) {
203                        $objSiteSess = new SC_SiteSession;
204                        $objSiteSess->setRegistFlag();
205                        $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
206
207                        SC_Response_Ex::sendRedirect(ROOT_URLPATH . USER_DIR . 'gmopg_oneclick_confirm.php', array(), false, true);
208                        exit;
209                    }
210
211                    SC_Response_Ex::sendRedirect(CART_URLPATH);
212                    exit;
213                }
214                break;
215
216            default:
217                break;
218        }
219
220        // モバイル用 ポストバック処理
221        if(Net_UserAgent_Mobile::isMobile() === true) {
222            switch($mode) {
223                case 'select':
224                    // 規格1が設定されている場合
225                    if($this->tpl_classcat_find1) {
226                        // templateの変更
227                        $this->tpl_mainpage = "products/select_find1.tpl";
228                        break;
229                    }
230
231                case 'select2':
232                    $this->arrErr = $this->lfCheckError();
233
234                    // 規格1が設定されている場合
235                    if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
236                        // templateの変更
237                        $this->tpl_mainpage = "products/select_find1.tpl";
238                        break;
239                    }
240
241                    // 規格2が設定されている場合
242                    if($this->tpl_classcat_find2) {
243                        $this->arrErr = array();
244
245                        $this->tpl_mainpage = "products/select_find2.tpl";
246                        break;
247                    }
248
249                case 'selectItem':
250                    $this->arrErr = $this->lfCheckError();
251
252                    // 規格1が設定されている場合
253                    if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
254                        // templateの変更
255                        $this->tpl_mainpage = "products/select_find2.tpl";
256                        break;
257                    }
258
259                    $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$_POST['classcategory_id1']][$_POST['classcategory_id2']]['product_class_id'];
260
261                    // 商品数の選択を行う
262                    $this->tpl_mainpage = "products/select_item.tpl";
263                    break;
264
265                default:
266                    $this->tpl_mainpage = "products/detail.tpl";
267                    break;
268            }
269        }
270
271        // 商品詳細を取得
272        $this->arrProduct = $objProduct->getDetail($product_id);
273
274        // サブタイトルを取得
275        $this->tpl_subtitle = $this->arrProduct['name'];
276
277        // 関連カテゴリを取得
278        $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id);
279
280        // 商品ステータスを取得
281        $this->productStatus = $objProduct->getProductStatus($product_id);
282
283        // 画像ファイル指定がない場合の置換処理
284        $this->arrProduct['main_image']
285            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
286
287        $this->lfSetFile();
288        // 支払方法の取得
289        $this->arrPayment = $this->lfGetPayment();
290        // 入力情報を渡す
291        $this->arrForm = $this->objFormParam->getFormParamList();
292        //レビュー情報の取得
293        $this->arrReview = $this->lfGetReviewData($product_id);
294        // トラックバック情報の取得
295
296        // トラックバック機能の稼働状況チェック
297        if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
298            $this->arrTrackbackView = "OFF";
299        } else {
300            $this->arrTrackbackView = "ON";
301            $this->arrTrackback = $this->lfGetTrackbackData($product_id);
302        }
303        $this->trackback_url = TRACKBACK_TO_URL . $product_id;
304        //関連商品情報表示
305        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
306
307        $this->lfConvertParam();
308    }
309
310    /**
311     * デストラクタ.
312     *
313     * @return void
314     */
315    function destroy() {
316        parent::destroy();
317    }
318
319    /* プロダクトIDの正当性チェック */
320    function lfCheckProductId() {
321        // 管理機能からの確認の場合は、非公開の商品も表示する。
322        if (isset($_GET['admin']) && $_GET['admin'] == 'on') {
323            SC_Utils_Ex::sfIsSuccess(new SC_Session());
324            $status = true;
325            $where = 'del_flg = 0';
326        } else {
327            $status = false;
328            $where = 'del_flg = 0 AND status = 1';
329        }
330
331        if (defined('MOBILE_SITE')) {
332            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
333                $product_id = $_POST['product_id'];
334            } else {
335                $product_id = $_GET['product_id'];
336            }
337        } else {
338            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
339                $product_id = $_POST['product_id'];
340            } else {
341                $product_id = $_GET['product_id'];
342            }
343        }
344
345        $objDb = new SC_Helper_DB_Ex();
346        if(!SC_Utils_Ex::sfIsInt($product_id)
347            || SC_Utils_Ex::sfIsZeroFilling($product_id)
348            || !$objDb->sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where))
349            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
350        return $product_id;
351    }
352
353    /* ファイル情報の初期化 */
354    function lfInitFile() {
355        $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
356        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
357            $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);
358        }
359    }
360
361    /* 規格選択セレクトボックスの作成 */
362    function lfMakeSelect() {
363
364        // 選択されている規格
365        $classcategory_id1
366            = isset($_POST['classcategory_id1']) && is_numeric($_POST['classcategory_id1'])
367            ? $_POST['classcategory_id1']
368            : '';
369
370        $classcategory_id2
371            = isset($_POST['classcategory_id2']) && is_numeric($_POST['classcategory_id2'])
372            ? $_POST['classcategory_id2']
373            : '';
374
375        $this->js_lnOnload .= 'fnSetClassCategories('
376            . 'document.form1, '
377            . Services_JSON::encode($classcategory_id2)
378            . '); ';
379    }
380
381    /* 規格選択セレクトボックスの作成(モバイル) */
382    function lfMakeSelectMobile(&$objPage, $product_id) {
383
384        $objDb = new SC_Helper_DB_Ex();
385        $classcat_find1 = false;
386        $classcat_find2 = false;
387        // 在庫ありの商品の有無
388        $stock_find = false;
389
390        // 規格名一覧
391        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
392        // 規格分類名一覧
393        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
394        /*
395         * FIXME
396         * パフォーマンスが出ないため,
397         * SC_Product::getProductsClassByProductIds() を使用した実装に変更
398         */
399        // 商品規格情報の取得
400        $arrProductsClass = $this->lfGetProductsClass($product_id);
401
402        // 規格1クラス名の取得
403        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
404        // 規格2クラス名の取得
405        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
406
407        // すべての組み合わせ数
408        $count = count($arrProductsClass);
409
410        $classcat_id1 = "";
411
412        $arrSele1 = array();
413        $arrSele2 = array();
414
415        for ($i = 0; $i < $count; $i++) {
416            // 在庫のチェック
417            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
418                continue;
419            }
420
421            $stock_find = true;
422
423            // 規格1のセレクトボックス用
424            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
425                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
426                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
427            }
428
429            // 規格2のセレクトボックス用
430            if($arrProductsClass[$i]['classcategory_id1'] == $_POST['classcategory_id1'] and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
431                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
432                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
433            }
434        }
435
436        // 規格1
437        $objPage->arrClassCat1 = $arrSele1;
438        $objPage->arrClassCat2 = $arrSele2;
439
440        // 規格1が設定されている
441        if(isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
442            $classcat_find1 = true;
443        }
444
445        // 規格2が設定されている
446        if(isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
447            $classcat_find2 = true;
448        }
449
450        $objPage->tpl_classcat_find1 = $classcat_find1;
451        $objPage->tpl_classcat_find2 = $classcat_find2;
452        $objPage->tpl_stock_find = $stock_find;
453    }
454
455    /* パラメータ情報の初期化 */
456    function lfInitParam() {
457        $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
458        $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
459        $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
460    }
461
462    /* 商品規格情報の取得 */
463    function lfGetProductsClass($product_id) {
464        $objProduct = new SC_Product();
465        return $objProduct->getProductsClassFullByProductId($product_id);
466    }
467
468    /* 登録済み関連商品の読み込み */
469    function lfPreGetRecommendProducts($product_id) {
470        $arrRecommend = array();
471        $objQuery = new SC_Query();
472        $objQuery->setOrder("rank DESC");
473        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
474        $max = count($arrRet);
475        $no = 0;
476        // FIXME SC_Product クラスを使用した実装
477        $from = "vw_products_allclass AS T1 "
478                . " JOIN ("
479                . " SELECT max(T2.rank) AS product_rank, "
480                . "        T2.product_id"
481                . "   FROM dtb_product_categories T2  "
482                . " GROUP BY product_id) AS T3 USING (product_id)";
483        $objQuery->setOrder("T3.product_rank DESC");
484        for($i = 0; $i < $max; $i++) {
485            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1";
486            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, T3.product_rank", $from, $where, array($arrRet[$i]['recommend_product_id']));
487
488            if(count($arrProductInfo) > 0) {
489                $arrRecommend[$no] = $arrProductInfo[0];
490                $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
491                $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
492                $no++;
493            }
494        }
495        return $arrRecommend;
496    }
497
498    /* 入力内容のチェック */
499    function lfCheckError() {
500
501        switch ($this->getMode()) {
502        case 'add_favorite':
503            $objCustomer = new SC_Customer();
504            $objErr = new SC_CheckError();
505            $customer_id = $objCustomer->getValue('customer_id');
506            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
507                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
508            }
509            break;
510        default:
511            // 入力データを渡す。
512            $arrRet =  $this->objFormParam->getHashArray();
513            $objErr = new SC_CheckError($arrRet);
514            $objErr->arrErr = $this->objFormParam->checkError();
515
516            // 複数項目チェック
517            if ($this->tpl_classcat_find1) {
518                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK"));
519            }
520            if ($this->tpl_classcat_find2) {
521                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK"));
522            }
523            break;
524        }
525
526        return $objErr->arrErr;
527    }
528
529    //閲覧履歴新規登録
530    function lfRegistReadingData($product_id, $customer_id){
531        $objQuery = new SC_Query;
532        $sqlval['customer_id'] = $customer_id;
533        $sqlval['reading_product_id'] = $product_id;
534        $sqlval['create_date'] = 'NOW()';
535        $sqlval['update_date'] = 'NOW()';
536        $objQuery->insert("dtb_customer_reading", $sqlval);
537    }
538
539    //商品ごとのレビュー情報を取得する
540    function lfGetReviewData($id) {
541        $objQuery = new SC_Query;
542        //商品ごとのレビュー情報を取得する
543        $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
544        $from = "dtb_review";
545        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
546        $arrval[] = $id;
547        $arrReview = $objQuery->select($col, $from, $where, $arrval);
548        return $arrReview;
549    }
550
551    /*
552     * 商品ごとのトラックバック情報を取得する
553     *
554     * @param $product_id
555     * @return $arrTrackback
556     */
557    function lfGetTrackbackData($product_id) {
558
559        $arrTrackback = array();
560
561        $objQuery = new SC_Query;
562        //商品ごとのトラックバック情報を取得する
563        $col = "blog_name, url, title, excerpt, title, create_date";
564        $from = "dtb_trackback";
565        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX;
566        $arrval[] = $product_id;
567        $arrTrackback = $objQuery->select($col, $from, $where, $arrval);
568        return $arrTrackback;
569    }
570
571    //支払方法の取得
572    //payment_id    1:クレジット 2:ショッピングローン
573    function lfGetPayment() {
574        $objQuery = new SC_Query;
575        $col = "payment_id, rule, payment_method";
576        $from = "dtb_payment";
577        $where = "del_flg = 0";
578        $order = "payment_id";
579        $objQuery->setOrder($order);
580        $arrRet = $objQuery->select($col, $from, $where);
581        return $arrRet;
582    }
583
584    function lfConvertParam() {
585        if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
586        $value = $this->arrForm['quantity']['value'];
587        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
588    }
589
590    /*
591     * ファイルの情報をセットする
592     *
593     */
594    function lfSetFile() {
595        // DBからのデータを引き継ぐ
596        $this->objUpFile->setDBFileList($this->arrProduct);
597        // ファイル表示用配列を渡す
598        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
599
600        // サブ画像の有無を判定
601        $this->subImageFlag = false;
602        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
603            if ($this->arrFile["sub_image" . $i]["filepath"] != "") {
604                $this->subImageFlag = true;
605            }
606        }
607    }
608
609    /*
610     * お気に入り商品登録
611     */
612    function lfRegistFavoriteProduct($customer_id, $product_id) {
613        $objQuery = new SC_Query();
614        $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id));
615
616        if ($count == 0) {
617            $sqlval['customer_id'] = $customer_id;
618            $sqlval['product_id'] = $product_id;
619            $sqlval['update_date'] = "now()";
620            $sqlval['create_date'] = "now()";
621
622            $objQuery->begin();
623            $objQuery->insert('dtb_customer_favorite_products', $sqlval);
624            $objQuery->commit();
625        }
626    }
627
628}
629?>
Note: See TracBrowser for help on using the repository browser.