Source for file LC_Page_Products_Detail.php
Documentation is available at LC_Page_Products_Detail.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
if (file_exists(MODULE_REALDIR . "mdl_gmopg/inc/function.php")) {
require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php';
* @author LOCKON CO.,LTD.
* @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
$masterData = new SC_DB_MasterData_Ex();
$this->arrSTATUS = $masterData->getMasterData("mtb_status");
$this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
$objCustomer = new SC_Customer_Ex();
$this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
$this->mode = $this->getMode();
$objProduct = new SC_Product_Ex();
$objProduct->setProductsClassByProductIds(array($product_id));
$this->tpl_class_name1 = $objProduct->className1[$product_id];
$this->tpl_class_name2 = $objProduct->className2[$product_id];
$this->arrClassCat1 = $objProduct->classCats1[$product_id];
$this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
$this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
$this->tpl_stock_find = $objProduct->stock_find[$product_id];
$this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
$this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
// 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
if ($this->tpl_stock_find) {
$this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
$this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}';
$this->tpl_onload .= 'lnOnLoad();';
if(SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
$this->tpl_product_id = $product_id;
$this->tpl_classcat_find1,
$this->tpl_classcat_find2);
if (count($this->arrErr) == 0) {
$objCartSess = new SC_CartSession_Ex();
$product_class_id = $this->objFormParam->getValue('product_class_id');
$objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
SC_Response_Ex::sendRedirect(CART_URLPATH);
// ログイン中のユーザが商品をお気に入りにいれる処理
if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0 ) {
if(count($this->arrErr) == 0){
case "add_favorite_sphone":
// ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0 ) {
if(count($this->arrErr) == 0){
* $_SESSION['cart_referer_url'] を上書きさせないために、
$_SESSION['cart_referer_url'] = $netURL->getURL();
if(SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
if($this->tpl_classcat_find1) {
$this->tpl_mainpage = "products/select_find1.tpl";
$this->tpl_mainpage = "products/select_item.tpl";
// 規格1が設定されていて、エラーを検出した場合
if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
$this->tpl_mainpage = "products/select_find1.tpl";
if($this->tpl_classcat_find2) {
$this->tpl_mainpage = "products/select_find2.tpl";
// 規格2が設定されていて、エラーを検出した場合
if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
$this->tpl_mainpage = "products/select_find2.tpl";
$value1 = $this->objFormParam->getValue('classcategory_id1');
$value2 = $this->objFormParam->getValue('classcategory_id2');
$value1 = '__unselected';
$value2 = '__unselected';
$this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
// この段階では、数量の入力チェックエラーを出させない。
unset ($this->arrErr['quantity']);
$this->tpl_mainpage = "products/select_item.tpl";
// この段階でエラーが出る場合は、数量の入力エラーのはず
if (count($this->arrErr)) {
$this->tpl_mainpage = "products/select_item.tpl";
$this->tpl_mainpage = "products/detail.tpl";
$this->arrProduct = $objProduct->getDetail($product_id);
$this->tpl_subtitle = $this->arrProduct['name'];
$this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
$this->productStatus = $objProduct->getProductStatus($product_id);
$this->arrProduct['main_image']
= SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
$this->subImageFlag = $this->lfSetFile($this->objUpFile,$this->arrProduct,$this->arrFile);
if ($objCustomer->isLoginSuccess() === true) {
$this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
// 管理機能からの確認の場合は、非公開の商品も表示する。
if (isset ($admin_mode) && $admin_mode == 'on') {
SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex());
$where = 'del_flg = 0 AND status = 1';
if(!SC_Utils_Ex::sfIsInt($product_id)
|| SC_Utils_Ex::sfIsZeroFilling($product_id)
|| !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array) $product_id, $where))
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
$objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE);
for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++ ) {
$objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
return 'fnSetClassCategories('
. SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
/* 規格選択セレクトボックスの作成(モバイル) */
$arrClassName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_class", "class_id", 'name');
$arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_classcategory", "classcategory_id", 'name');
$objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
$objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
$count = count($arrProductsClass);
for ($i = 0; $i < $count; $i++ ) {
if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
$classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
$arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
if($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
$classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
$arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
$objPage->arrClassCat1 = $arrSele1;
$objPage->arrClassCat2 = $arrSele2;
if(isset ($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
if(isset ($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
$objPage->tpl_classcat_find1 = $classcat_find1;
$objPage->tpl_classcat_find2 = $classcat_find2;
$objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("数量", 'quantity', INT_LEN, 'n', array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("管理者ログイン", 'admin', INT_LEN, 'a', array('ALNUM_CHECK',"MAX_LENGTH_CHECK"));
$objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("お気に入り商品ID", "favorite_product_id", INT_LEN, 'n', array("ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->setParam($_REQUEST);
$objFormParam->convParam();
return $objFormParam->getFormParamList();
$objProduct = new SC_Product_Ex();
return $objProduct->getProductsClassFullByProductId($product_id);
$objProduct = new SC_Product_Ex();
$objQuery = & SC_Query_Ex::getSingletonInstance();
$objQuery->setOrder("rank DESC");
$arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
$arrRecommendProductId = array();
foreach($arrRecommendData as $recommend){
$arrRecommendProductId[] = $recommend["recommend_product_id"];
$arrRecommendData[$recommend["recommend_product_id"]] = $recommend['comment'];
$objQuery = & SC_Query_Ex::getSingletonInstance();
$arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
// FIXME SC_Productあたりにソート処理はもってくべき
foreach($arrProducts as $item) {
$arrProducts2[ $item['product_id'] ] = $item;
foreach($arrRecommendProductId as $product_id) {
$arrProducts2[$product_id]['comment'] = $arrRecommendData[$product_id];
$arrRecommend[] = $arrProducts2[$product_id];
function lfCheckError($mode,&$objFormParam,$tpl_classcat_find1 = null ,$tpl_classcat_find2 = null) {
case 'add_favorite_sphone':
$objCustomer = new SC_Customer_Ex();
$objErr = new SC_CheckError_Ex();
$customer_id = $objCustomer->getValue('customer_id');
if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
$objErr->arrErr['add_favorite'. $favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
$arrRet = $objFormParam->getHashArray();
$objErr = new SC_CheckError_Ex($arrRet);
$objErr->arrErr = $objFormParam->checkError();
if ($tpl_classcat_find1) {
$objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK"));
if ($tpl_classcat_find2) {
$objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK"));
$objQuery = & SC_Query_Ex::getSingletonInstance();
$col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
$where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
$arrReview = $objQuery->select($col, $from, $where, $arrval);
function lfSetFile($objUpFile,$arrProduct,&$arrFile) {
$objUpFile->setDBFileList($arrProduct);
$arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
for ($i = 1; $i <= PRODUCTSUB_MAX; $i++ ) {
if ($arrFile["sub_image" . $i]['filepath'] != "") {
// ログイン中のユーザが商品をお気に入りにいれる処理
if(!SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $favorite_product_id, "del_flg = 0 AND status = 1")) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
$objQuery = & SC_Query_Ex::getSingletonInstance();
$count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $favorite_product_id));
$sqlval['customer_id'] = $customer_id;
$sqlval['product_id'] = $favorite_product_id;
$sqlval['update_date'] = 'CURRENT_TIMESTAMP';
$sqlval['create_date'] = 'CURRENT_TIMESTAMP';
$objQuery->insert('dtb_customer_favorite_products', $sqlval);
$this->just_added_favorite = true;
Documentation generated on Fri, 24 Feb 2012 14:02:11 +0900 by Seasoft
|