tpl_mainpage = "rss/product.tpl"; $this->encode = "UTF-8"; $this->title = "商品一覧情報"; } /** * Page のプロセス. * * @return void */ function process() { $objQuery = new SC_Query(); $objView = new SC_SiteView(); $objSiteInfo = new SC_SiteInfo(); //店舗情報をセット $arrSiteInfo = $objSiteInfo->data; //商品IDを取得 $product_id = $_GET['product_id']; $mode = $_GET['mode']; if(($product_id != "" and is_numeric($product_id)) or $mode == "all"){ //商品詳細を取得 ($mode == "all") ? $arrProduct = $this->lfGetProductsDetail($objQuery, $mode) : $arrProduct = $this->lfGetProductsDetail($objQuery, $product_id); // 値のセットし直し foreach($arrProduct as $key => $val){ //商品価格を税込みに編集 $arrProduct[$key]["price02"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); // 画像ファイルのURLセット (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; // ポイント計算 $arrProduct[$key]["point"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); } }elseif($mode == "list"){ //商品一覧を取得 $arrProduct = $objQuery->getall("SELECT product_id, name AS product_name FROM dtb_products"); }else{ $arrProduct = $this->lfGetProductsAllclass($objQuery); // 値のセットし直し foreach($arrProduct as $key => $val){ //商品価格を税込みに編集 $arrProduct[$key]["price01_max"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price01_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); $arrProduct[$key]["price01_min"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price01_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); $arrProduct[$key]["price02_max"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); $arrProduct[$key]["price02_min"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); // 画像ファイルのURLセット (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; // ポイント計算 $arrProduct[$key]["point_max"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_max"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); $arrProduct[$key]["point_min"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_min"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); // ポイント計算 $arrProduct[$key]["create_date"] = gmdate('r', strtotime($arrProduct[$key]["create_date"])); } } //商品情報をセット $this->arrProduct = $arrProduct; if(is_array(SC_Utils_Ex::sfswaparray($arrProduct))){ $this->arrProductKeys = array_keys(SC_Utils_Ex::sfswaparray($arrProduct)); } //店舗情報をセット $this->arrSiteInfo = $arrSiteInfo; //セットしたデータをテンプレートファイルに出力 $objView->assignobj($this); //キャッシュしない(念のため) header("Pragma: no-cache"); //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため) header("Content-type: application/xml"); DETAIL_P_HTML; //画面表示 $objView->display($this->tpl_mainpage, true); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } /** * 商品情報を取得する * * @param SC_Query $objQuery DB操作クラス * @param integer $product_id 商品ID * @return array $arrProduct 取得結果を配列で返す */ function lfGetProductsDetail(&$objQuery, $product_id = "all"){ $sql = ""; $sql .= "SELECT "; $sql .= " prod.product_id "; $sql .= " ,prod.name AS product_name "; $sql .= " ,prod.category_id "; $sql .= " ,prod.point_rate "; $sql .= " ,prod.comment3 "; $sql .= " ,prod.main_list_comment "; $sql .= " ,prod.main_list_image "; $sql .= " ,prod.main_comment "; $sql .= " ,prod.main_image "; $sql .= " ,prod.main_large_image "; $sql .= " ,cls.product_code "; $sql .= " ,cls.price01 "; $sql .= " ,cls.price02 "; $sql .= " ,cls.classcategory_id1 "; $sql .= " ,cls.classcategory_id2 "; $sql .= " ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id1) AS classcategory_name1 "; $sql .= " ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id2) AS classcategory_name2 "; $sql .= " ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = prod.category_id) AS category_name"; $sql .= " FROM dtb_products AS prod, dtb_products_class AS cls"; $sql .= " WHERE prod.product_id = cls.product_id AND prod.del_flg = 0 AND prod.status = 1"; if($product_id != "all"){ $sql .= " AND prod.product_id = ?"; $arrval = array($product_id); } $sql .= " ORDER BY prod.product_id, cls.classcategory_id1, cls.classcategory_id2"; $arrProduct = $objQuery->getall($sql, $arrval); return $arrProduct; } /** * 商品情報を取得する(vw_products_allclass使用) * * @param SC_Query $objQuery DB操作クラス * @return array $arrProduct 取得結果を配列で返す */ function lfGetProductsAllclass($objQuery){ $sql = ""; $sql .= "SELECT product_id ,name as product_name ,category_id ,point_rate ,comment3 ,main_list_comment ,main_image ,main_list_image ,product_code_min ,product_code_max ,price01_min ,price01_max ,price02_min ,price02_max ,create_date ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = allcls.category_id) AS category_name ,(SELECT main_large_image FROM dtb_products AS prod WHERE prod.product_id = allcls.product_id) AS main_large_image FROM vw_products_allclass as allcls WHERE allcls.del_flg = 0 AND allcls.status = 1"; $sql .= " ORDER BY allcls.product_id DESC"; $arrProduct = $objQuery->getall($sql); return $arrProduct; } } ?>