Ignore:
Timestamp:
2009/12/07 15:08:06 (14 years ago)
Author:
kajiwara
Message:

EC-CUBE Ver2.4.2 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=207

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2/data/class/pages/products/LC_Page_Products_Detail.php

    r18177 r18432  
    8787        $helper->sfGetPageLayout($this, false, "products/detail.php"); 
    8888 
    89         // ログイン中のユーザが商品をお気に入りにいれる処理 
    90         if( $objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) { 
    91             // 値の正当性チェック 
    92             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")) { 
    93                 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 
    94                 exit; 
    95             } else { 
    96                 $this->arrErr = $this->lfCheckError(); 
    97                 if(count($this->arrErr) == 0) { 
    98                     $customer_id = $objCustomer->getValue('customer_id'); 
    99                     $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']); 
    100                 } 
    101             } 
    102         } 
    103  
    10489        // パラメータ管理クラス 
    10590        $this->objFormParam = new SC_FormParam(); 
     
    217202            break; 
    218203 
     204        case 'add_favorite': 
     205            // お気に入りに追加する 
     206            $this->lfAddFavoriteProduct($objCustomer); 
     207            break; 
     208 
    219209        default: 
    220210            break; 
     
    223213        $objQuery = new SC_Query(); 
    224214        // DBから商品情報を取得する。 
    225         $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE product_id = alldtl.product_id AND customer_id = ?) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $tmp_id)); 
     215        $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = alldtl.product_id) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $tmp_id)); 
    226216        $this->arrProduct = $arrRet[0]; 
    227217 
     
    734724                . "   FROM dtb_product_categories T2  " 
    735725                . " GROUP BY product_id) AS T3 USING (product_id)"; 
    736         $objQuery->setorder("product_rank DESC"); 
     726        $objQuery->setorder("T3.product_rank DESC"); 
    737727        for($i = 0; $i < $max; $i++) { 
    738728            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1"; 
    739             $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, product_rank", $from, $where, array($arrRet[$i]['recommend_product_id'])); 
     729            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, T3.product_rank", $from, $where, array($arrRet[$i]['recommend_product_id'])); 
    740730 
    741731            if(count($arrProductInfo) > 0) { 
     
    751741    /* 入力内容のチェック */ 
    752742    function lfCheckError() { 
    753         if ($_POST['mode'] == "add_favorite") { 
    754             $objCustomer = new SC_Customer(); 
    755             $objErr = new SC_CheckError(); 
    756             $customer_id = $objCustomer->getValue('customer_id'); 
    757             if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { 
    758                 $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 
    759             } 
    760         } else { 
    761             // 入力データを渡す。 
    762             $arrRet =  $this->objFormParam->getHashArray(); 
    763             $objErr = new SC_CheckError($arrRet); 
    764             $objErr->arrErr = $this->objFormParam->checkError(); 
    765  
    766             // 複数項目チェック 
    767             if ($this->tpl_classcat_find1) { 
    768                 $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
    769             } 
    770             if ($this->tpl_classcat_find2) { 
    771                 $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
    772             } 
     743        // 入力データを渡す。 
     744        $arrRet =  $this->objFormParam->getHashArray(); 
     745        $objErr = new SC_CheckError($arrRet); 
     746        $objErr->arrErr = $this->objFormParam->checkError(); 
     747 
     748        // 複数項目チェック 
     749        if ($this->tpl_classcat_find1) { 
     750            $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
     751        } 
     752        if ($this->tpl_classcat_find2) { 
     753            $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
    773754        } 
    774755 
     
    855836    } 
    856837 
    857         /* 
     838    /** 
     839     * 商品をお気に入りにいれる処理 
     840     * @param object 顧客管理用クラスオブジェクト 
     841     */ 
     842    function lfAddFavoriteProduct($objCustomer) 
     843    { 
     844        // ログイン中のユーザーかつ、お気に入り商品機能ONの時 
     845        if ( $objCustomer->isLoginSuccess() === true && OPTION_FAVOFITE_PRODUCT == 1 ){ 
     846            $add_favorite_product_id = $_POST['favorite_product_id'];    // お気に入りに追加する商品ID 
     847            $customer_id = $objCustomer->getValue('customer_id');        // ログイン中の顧客ID 
     848 
     849            // お気に入りに商品を追加する際のエラーチェックを行う 
     850            $this->arrErr = array();    // エラー内容 
     851            $this->lfCheckAddFavoriteProduct($customer_id, $add_favorite_product_id); 
     852 
     853            if( count($this->arrErr) == 0 ) { 
     854                // お気に入りに商品を追加する 
     855                $this->lfRegistFavoriteProduct($customer_id, $add_favorite_product_id); 
     856            } 
     857        } 
     858        return ; 
     859    } 
     860 
     861    /** 
     862     * 商品をお気に入りにいれる際のエラーチェックを行う 
     863     * @param int $customer_id 顧客ID 
     864     * @param int $add_favorite_product_id お気に入りに追加する商品ID 
     865     */ 
     866    function lfCheckAddFavoriteProduct($customer_id, $add_favorite_product_id) 
     867    { 
     868        // 値の正当性チェック 
     869        $objDb = new SC_Helper_DB_Ex(); 
     870        if( !SC_Utils_Ex::sfIsInt($add_favorite_product_id) || !$objDb->sfIsRecord('dtb_products', 'product_id', $add_favorite_product_id, 'del_flg = 0 AND status = 1') ) { 
     871            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 
     872            exit; 
     873        } 
     874 
     875        // 既にお気に入り商品として追加されていないかチェック 
     876        if (SC_Helper_DB_Ex::sfDataExists( 'dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $add_favorite_product_id)) ) { 
     877            $this->arrErr['add_favorite'.$add_favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 
     878            $this->add_favorite_product_id = $add_favorite_product_id; 
     879        } 
     880    } 
     881 
     882    /** 
    858883     * お気に入り商品登録 
     884     * @param int $customer_id 顧客ID 
     885     * @param int $add_favorite_product_id お気に入りに追加する商品ID 
    859886     */ 
    860     function lfRegistFavoriteProduct($customer_id, $product_id) { 
     887    function lfRegistFavoriteProduct($customer_id, $add_favorite_product_id) { 
     888        $sqlval = array(); 
     889        $sqlval['customer_id'] = $customer_id; 
     890        $sqlval['product_id'] = $add_favorite_product_id; 
     891        $sqlval['update_date'] = "now()"; 
     892        $sqlval['create_date'] = "now()"; 
     893 
    861894        $objQuery = new SC_Query(); 
    862         $objConn = new SC_DbConn(); 
    863         $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id)); 
    864  
    865         if ($count == 0) { 
    866             $sqlval['customer_id'] = $customer_id; 
    867             $sqlval['product_id'] = $product_id; 
    868             $sqlval['update_date'] = "now()"; 
    869             $sqlval['create_date'] = "now()"; 
    870  
    871             $objQuery->begin(); 
    872             $objQuery->insert('dtb_customer_favorite_products', $sqlval); 
    873             $objQuery->commit(); 
    874         } 
     895        $objQuery->begin(); 
     896        $objQuery->insert('dtb_customer_favorite_products', $sqlval); 
     897        $objQuery->commit(); 
    875898    } 
    876899} 
Note: See TracChangeset for help on using the changeset viewer.