예제 #1
0
 public function doAction($arrParam)
 {
     $arrRequest = $this->doInitParam($arrParam);
     if (!$this->isParamError()) {
         $objProduct = new SC_Product_Ex();
         switch ($arrRequest['IdType']) {
             case 'product_code':
                 $search_column = 'product_code';
                 break;
             case 'product_class_id':
                 $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']);
                 break;
             case 'product_id':
             default:
                 $arrProduct = $objProduct->getDetail($arrRequest['ItemId']);
                 break;
         }
         $objProduct->setProductsClassByProductIds(array($arrProduct['product_id']));
         if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') {
             unset($arrProduct['note']);
             $this->setResponse('product_id', $arrProduct['product_id']);
             $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']);
             $this->setResponse('Title', $arrProduct['name']);
             $this->setResponse('ItemAttributes', $arrProduct);
             return true;
         } else {
             $this->addError('ItemLookup.Error', t('c_* The requested information was not found._01'));
         }
     }
     return false;
 }
 /**
  *
  * @param SC_Product_Ex $objProduct
  */
 public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objDb = new SC_Helper_DB_Ex();
     $arrOrderVal = array();
     // 表示順序
     switch ($this->orderby) {
         // ダウンロード順
         case 'download':
             $status = ORDER_PRE_END;
             $objProduct->setProductsOrder('count(*)', "(SELECT B.* FROM dtb_order A INNER JOIN dtb_order_detail B USING(order_id) WHERE A.del_flg = 0 AND A.status = {$status})", 'ASC');
             break;
             // 販売価格が安い順
         // 販売価格が安い順
         case 'price':
             $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
             break;
             // 新着順
         // 新着順
         case 'date':
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date')) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } else {
                 $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
             }
             break;
         default:
             // FIXME 指定した カラムが損z内下場合はそのカラムをキーとする。
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date') && strlen($this->orderby) == 0) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } elseif ($objDb->sfColumnExists('dtb_products', $this->orderby)) {
                 $objProduct->setProductsOrder($this->orderby, 'dtb_products', 'DESC');
                 break;
             }
         case "rank":
             if (strlen($searchCondition['where_category']) >= 1) {
                 $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ')';
                 $arrOrderVal = $searchCondition['arrvalCategory'];
             } else {
                 $dtb_product_categories = 'dtb_product_categories';
             }
             $col = 'MAX(T3.rank * 2147483648 + T2.rank)';
             $from = "{$dtb_product_categories} T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
             $where = 'T2.product_id = alldtl.product_id';
             $sub_sql = $objQuery->getSql($col, $from, $where);
             $objQuery->setOrder("({$sub_sql}) DESC ,product_id DESC");
             break;
     }
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($disp_number, $startno);
     $objQuery->setWhere($searchCondition['where']);
     // 表示すべきIDとそのIDの並び順を一気に取得
     $arrProductId = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrOrderVal));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
     // 規格を設定
     $objProduct->setProductsClassByProductIds($arrProductId);
     $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);
     foreach ($arrProducts as $product_id => &$arrProduct) {
         if ($product_id == 'productStatus') {
             continue;
         }
         $category_id = $objProduct->getCategoryIds($product_id);
         $arrProduct["category_id"] = array_shift($category_id);
         $arrProduct["category"] = $this->arrCategory[$arrProduct["category_id"]];
         $arrProduct["category_name"] = $arrProduct["category"]["category_name"];
         if ($objDb->sfColumnExists('dtb_category', 'category_code')) {
             $arrProduct["category_code"] = $arrProduct["category"]["category_code"];
             $arrProduct["category_image1"] = $arrProduct["category"]["category_image1"] ?: 0;
             $arrProduct["category_image2"] = $arrProduct["category"]["category_image2"] ?: 0;
             $arrProduct["category_image3"] = $arrProduct["category"]["category_image3"] ?: 0;
             $arrProduct["category_image4"] = $arrProduct["category"]["category_image4"] ?: 0;
             $arrProduct["category_image5"] = $arrProduct["category"]["category_image5"] ?: 0;
         }
     }
     return $arrProducts;
 }
 /**
  * 
  * @return void
  */
 function doMobileSelectItem()
 {
     $objProduct = new SC_Product_Ex();
     $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
     // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
     // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
     unset($this->arrErr['product_class_id']);
     unset($this->arrErr['quantity']);
     // 規格2が設定されていて、エラーを検出した場合
     if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
         // templateの変更
         $this->tpl_mainpage = 'products/select_find2.tpl';
         return;
     }
     $product_id = $this->objFormParam->getValue('product_id');
     $value1 = $this->objFormParam->getValue('classcategory_id1');
     if (strlen($value1) === 0) {
         $value1 = '__unselected';
     }
     // 規格2が設定されている場合.
     if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
         $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
     } else {
         $value2 = '#0';
     }
     $objProduct->setProductsClassByProductIds(array($product_id));
     $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
     // 数量の入力を行う
     $this->tpl_mainpage = 'products/select_item.tpl';
 }
 /**
  * Page のAction.
  *
  * @return void
  */
 function action()
 {
     // 会員クラス
     $objCustomer = new SC_Customer_Ex();
     // パラメーター管理クラス
     $this->objFormParam = new SC_FormParam_Ex();
     // パラメーター情報の初期化
     $this->arrForm = $this->lfInitParam($this->objFormParam);
     // ファイル管理クラス
     $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
     // ファイル情報の初期化
     $this->objUpFile = $this->lfInitFile($this->objUpFile);
     // プロダクトIDの正当性チェック
     $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'));
     $this->mode = $this->getMode();
     $objProduct = new SC_Product_Ex();
     $objProduct->setProductsClassByProductIds(array($product_id));
     // 規格1クラス名
     $this->tpl_class_name1 = $objProduct->className1[$product_id];
     // 規格2クラス名
     $this->tpl_class_name2 = $objProduct->className2[$product_id];
     // 規格1
     $this->arrClassCat1 = $objProduct->classCats1[$product_id];
     // 規格1が設定されている
     $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
     // 規格2が設定されている
     $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->js_lnOnload .= $this->lfMakeSelect();
     }
     $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->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
     }
     // 商品IDをFORM内に保持する
     $this->tpl_product_id = $product_id;
     switch ($this->mode) {
         case 'cart':
             $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $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);
                 SC_Response_Ex::actionExit();
             }
             break;
         case 'add_favorite':
             // ログイン中のユーザが商品をお気に入りにいれる処理
             if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
                 $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
                 if (count($this->arrErr) == 0) {
                     if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
                         $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
                         $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
                         SC_Response_Ex::actionExit();
                     }
                 }
             }
             break;
         case 'add_favorite_sphone':
             // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
             if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
                 $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
                 if (count($this->arrErr) == 0) {
                     if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
                         $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
                         $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
                         print 'true';
                         SC_Response_Ex::actionExit();
                     }
                 }
                 print 'error';
                 SC_Response_Ex::actionExit();
             }
             break;
         case 'select':
         case 'select2':
         case 'selectItem':
             /**
              * モバイルの数量指定・規格選択の際に、
              * $_SESSION['cart_referer_url'] を上書きさせないために、
              * 何もせずbreakする。
              */
             break;
         default:
             // カート「戻るボタン」用に保持
             $netURL = new Net_URL();
             $_SESSION['cart_referer_url'] = $netURL->getURL();
             break;
     }
     // モバイル用 ポストバック処理
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         switch ($this->mode) {
             case 'select':
                 // 規格1が設定されている場合
                 if ($this->tpl_classcat_find1) {
                     // templateの変更
                     $this->tpl_mainpage = 'products/select_find1.tpl';
                     break;
                 }
                 // 数量の入力を行う
                 $this->tpl_mainpage = 'products/select_item.tpl';
                 break;
             case 'select2':
                 $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
                 // 規格1が設定されていて、エラーを検出した場合
                 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
                     // templateの変更
                     $this->tpl_mainpage = 'products/select_find1.tpl';
                     break;
                 }
                 // 規格2が設定されている場合
                 if ($this->tpl_classcat_find2) {
                     $this->arrErr = array();
                     $this->tpl_mainpage = 'products/select_find2.tpl';
                     break;
                 }
             case 'selectItem':
                 $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
                 // 規格2が設定されていて、エラーを検出した場合
                 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
                     // templateの変更
                     $this->tpl_mainpage = 'products/select_find2.tpl';
                     break;
                 }
                 $value1 = $this->objFormParam->getValue('classcategory_id1');
                 // 規格2が設定されている場合.
                 if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
                     $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
                 } else {
                     $value2 = '#0';
                 }
                 if (strlen($value1) === 0) {
                     $value1 = '__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';
                 break;
             case 'cart':
                 // この段階でエラーが出る場合は、数量の入力エラーのはず
                 if (count($this->arrErr)) {
                     // 数量の入力を行う
                     $this->tpl_mainpage = 'products/select_item.tpl';
                 }
                 break;
             default:
                 $this->tpl_mainpage = 'products/detail.tpl';
                 break;
         }
     }
     // 商品詳細を取得
     $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);
     //レビュー情報の取得
     $this->arrReview = $this->lfGetReviewData($product_id);
     //関連商品情報表示
     $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
     // ログイン判定
     if ($objCustomer->isLoginSuccess() === true) {
         //お気に入りボタン表示
         $this->tpl_login = 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));
     }
 }
예제 #5
0
 /**
  * @param SC_Product_Ex $objProduct
  */
 public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrOrderVal = array();
     // 表示順序
     switch ($this->orderby) {
         // 販売価格が安い順
         case 'price':
             $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
             break;
             // 新着順
         // 新着順
         case 'date':
             $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
             break;
         default:
             if (strlen($searchCondition['where_category']) >= 1) {
                 $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ')';
                 $arrOrderVal = $searchCondition['arrvalCategory'];
             } else {
                 $dtb_product_categories = 'dtb_product_categories';
             }
             $col = 'MAX(T3.rank * 2147483648 + T2.rank)';
             $from = "{$dtb_product_categories} T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
             $where = 'T2.product_id = alldtl.product_id';
             $sub_sql = $objQuery->getSql($col, $from, $where);
             $objQuery->setOrder("({$sub_sql}) DESC ,product_id DESC");
             break;
     }
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($disp_number, $startno);
     $objQuery->setWhere($searchCondition['where']);
     // 表示すべきIDとそのIDの並び順を一気に取得
     $arrProductId = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrOrderVal));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
     // 規格を設定
     $objProduct->setProductsClassByProductIds($arrProductId);
     $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);
     return $arrProducts;
 }
예제 #6
0
 /**
  * Page のAction.
  *
  * @return void
  */
 function action()
 {
     // 会員クラス
     $objCustomer = new SC_Customer_Ex();
     // パラメーター管理クラス
     $this->objFormParam = new SC_FormParam_Ex();
     // パラメーター情報の初期化
     $this->arrForm = $this->lfInitParam($this->objFormParam);
     // ファイル管理クラス
     $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
     // ファイル情報の初期化
     $this->objUpFile = $this->lfInitFile($this->objUpFile);
     // プロダクトIDの正当性チェック
     $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'));
     $this->mode = $this->getMode();
     $objProduct = new SC_Product_Ex();
     $objProduct->setProductsClassByProductIds(array($product_id));
     // 規格1クラス名
     $this->tpl_class_name1 = $objProduct->className1[$product_id];
     // 規格2クラス名
     $this->tpl_class_name2 = $objProduct->className2[$product_id];
     // 規格1
     $this->arrClassCat1 = $objProduct->classCats1[$product_id];
     // 規格1が設定されている
     $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
     // 規格2が設定されている
     $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
     $this->tpl_stock_find = $objProduct->stock_find[$product_id];
     echo $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->js_lnOnload .= $this->lfMakeSelect();
     }
     $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->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
     }
     // 商品IDをFORM内に保持する
     $this->tpl_product_id = $product_id;
     switch ($this->mode) {
         case 'cart':
             $this->doCart();
             break;
         case 'add_favorite':
             $this->doAddFavorite($objCustomer);
             break;
         case 'add_favorite_sphone':
             $this->doAddFavoriteSphone($objCustomer);
             break;
         case 'select':
         case 'select2':
         case 'selectItem':
             /**
              * モバイルの数量指定・規格選択の際に、
              * $_SESSION['cart_referer_url'] を上書きさせないために、
              * 何もせずbreakする。
              */
             break;
         default:
             $this->doDefault();
             break;
     }
     // モバイル用 ポストバック処理
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         switch ($this->mode) {
             case 'select':
                 $this->doMobileSelect();
                 break;
             case 'select2':
                 $this->doMobileSelect2();
                 break;
             case 'selectItem':
                 $this->doMobileSelectItem();
                 break;
             case 'cart':
                 $this->doMobileCart();
                 break;
             default:
                 $this->doMobileDefault();
                 break;
         }
     }
     // 商品詳細を取得
     $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);
     //レビュー情報の取得
     $this->arrReview = $this->lfGetReviewData($product_id);
     //関連商品情報表示
     $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
     // ログイン判定
     if ($objCustomer->isLoginSuccess() === true) {
         //お気に入りボタン表示
         $this->tpl_login = 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));
     }
 }