Ignore:
Timestamp:
2009/05/15 16:30:40 (15 years ago)
Author:
kajiwara
Message:

2.4.0 正式版のコミット。コミット内容の詳細はこちら(http://svn.ec-cube.net/open_trac/query?status=closed&milestone=EC-CUBE2.4.0

File:
1 edited

Legend:

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

    r17468 r18007  
    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 
    89104        // パラメータ管理クラス 
    90105        $this->objFormParam = new SC_FormParam(); 
     
    121136        } 
    122137        // ログイン判定 
    123         if($objCustomer->isLoginSuccess()) { 
     138        if($objCustomer->isLoginSuccess() === true) { 
    124139            //お気に入りボタン表示 
    125140            $this->tpl_login = true; 
     
    208223        $objQuery = new SC_Query(); 
    209224        // DBから商品情報を取得する。 
    210         $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); 
     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)); 
    211226        $this->arrProduct = $arrRet[0]; 
    212227 
     
    224239        } 
    225240        // サブタイトルを取得 
    226         $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], $status); 
     241        $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'],'',$status); 
    227242        $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 
    228243        $this->tpl_subtitle = $arrFirstCat['name']; 
     
    754769    /* 入力内容のチェック */ 
    755770    function lfCheckError() { 
    756         // 入力データを渡す。 
    757         $arrRet =  $this->objFormParam->getHashArray(); 
    758         $objErr = new SC_CheckError($arrRet); 
    759         $objErr->arrErr = $this->objFormParam->checkError(); 
    760  
    761         // 複数項目チェック 
    762         if ($this->tpl_classcat_find1) { 
    763             $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
    764         } 
    765         if ($this->tpl_classcat_find2) { 
    766             $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
     771        if ($_POST['mode'] == "add_favorite") { 
     772            $objCustomer = new SC_Customer(); 
     773            $objErr = new SC_CheckError(); 
     774            $customer_id = $objCustomer->getValue('customer_id'); 
     775            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { 
     776                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 
     777            } 
     778        } else { 
     779            // 入力データを渡す。 
     780            $arrRet =  $this->objFormParam->getHashArray(); 
     781            $objErr = new SC_CheckError($arrRet); 
     782            $objErr->arrErr = $this->objFormParam->checkError(); 
     783 
     784            // 複数項目チェック 
     785            if ($this->tpl_classcat_find1) { 
     786                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
     787            } 
     788            if ($this->tpl_classcat_find2) { 
     789                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
     790            } 
    767791        } 
    768792 
     
    848872        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE); 
    849873    } 
     874 
     875        /* 
     876     * お気に入り商品登録 
     877     */ 
     878    function lfRegistFavoriteProduct($customer_id, $product_id) { 
     879        $objQuery = new SC_Query(); 
     880        $objConn = new SC_DbConn(); 
     881        $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id)); 
     882 
     883        if ($count == 0) { 
     884            $sqlval['customer_id'] = $customer_id; 
     885            $sqlval['product_id'] = $product_id; 
     886            $sqlval['update_date'] = "now()"; 
     887            $sqlval['create_date'] = "now()"; 
     888 
     889            $objQuery->begin(); 
     890            $objQuery->insert('dtb_customer_favorite_products', $sqlval); 
     891            $objQuery->commit(); 
     892        } 
     893    } 
    850894} 
    851895?> 
Note: See TracChangeset for help on using the changeset viewer.