バージョン選択

フォーラム

メニュー

オンライン状況

77 人のユーザが現在オンラインです。 (70 人のユーザが フォーラム を参照しています。)
登録ユーザ: 2
ゲスト: 75
swat gavangtv もっと...

サイト内検索

 > フロント機能 > 最近チェックした商品の履歴表示

フロント機能

新規スレッドを追加する

| 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
tmtqn543
投稿日時: 2008/12/26 16:10
対応状況: −−−
一人前
登録日: 2008/12/26
居住地: 長野県諏訪郡原村
投稿: 108
Re: 最近チェックした商品の履歴表示
新しいブロックを制作し該当ソースをいれたところ無事表示できました。ですが、やはり商品詳細ページでないと表示できませんでした。たとえば商品一覧ページなどでも表示させるにはどのようにしたら良いのでしょう?
EC-CUBE 2.3.0 です。
tonton
投稿日時: 2008/12/29 12:35
対応状況: −−−
仙人
登録日: 2008/8/14
居住地:
投稿: 437
Re: 最近チェックした商品の履歴表示
http://labs.edge.jp/cicindela/

ライブドアから既存サービスにオススメ商品を掲載するAPIが出たそうです。
これって、EC-CUBEで使えないでしょうかね。

とりあえず、情報共有のみアゲアゲ。
piko
投稿日時: 2009/2/22 1:05
対応状況: −−−
新米
登録日: 2009/2/22
居住地:
投稿: 1
Re: 最近チェックした商品の履歴表示
はじめまして

2.3.3で履歴の表示はできているのですが、
初回クッキーのエラー対処法が分からず困っております。

よろしければ、NULLチェックコードの追記方法を教えていただけないでしょうか?

よろしくお願いいたします。

*****************************************

自己解決しました。
ありがとうございました。
lucky7
投稿日時: 2009/2/25 1:44
対応状況: −−−
一人前
登録日: 2008/6/2
居住地: 東京近郊
投稿: 101
Re: 最近チェックした商品の履歴表示
とても有益な情報ありがとうございます!

しかし、導入部文で躓いています。

1:EC-CUBEバージョン:2.1.2なのですが、なぜか左側部分の一つしか表示されません。
2:履歴が保存されず、現在見ている詳細商品しか表示されません。

原因不明です(T_T)/~~~

data/class/pages/products/LC_Page_Products_Detail.php


    function process() {
        $objView = new SC_SiteView();
        $objCustomer = new SC_Customer();
        $objQuery = new SC_Query();
        $objDb = new SC_Helper_DB_Ex();

        // レイアウトデザインを取得
        $helper = new SC_Helper_PageLayout_Ex();
        $helper->sfGetPageLayout($this, false, "products/detail.php");

        // パラメータ管理クラス
        $this->objFormParam = new SC_FormParam();
        // パラメータ情報の初期化
        $this->lfInitParam();
        // POST値の取得
        $this->objFormParam->setParam($_POST);

        // ファイル管理クラス
        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
        // ファイル情報の初期化
        $this->lfInitFile();
        
        //2008.04.11 商品閲覧履歴取得
        $this->Get_ItemHistory();

        // 管理ページからの確認の場合は、非公開の商品も表示する。
        if(isset($_GET['admin']) && $_GET['admin'] == 'on') {
            SC_Utils_Ex::sfIsSuccess(new SC_Session());
            $status = true;
            $where = "del_flg = 0";
        } else {
            $status = false;
            $where = "del_flg = 0 AND status = 1";
        }
-------------------------------------------------
    //支払方法の取得
    //payment_id	1:クレジット 2:ショッピングローン
    function lfGetPayment() {
        $objQuery = new SC_Query;
        $col = "payment_id, rule, payment_method";
        $from = "dtb_payment";
        $where = "del_flg = 0";
        $order = "payment_id";
        $objQuery->setorder($order);
        $arrRet = $objQuery->select($col, $from, $where);
        return $arrRet;
    }

    function lfConvertParam() {
        if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
        $value = $this->arrForm['quantity']['value'];
        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
    }
    
    //2008.04.11 商品詳細閲覧履歴取得、表示データ取得処理
    function Get_ItemHistory() {
        $cnt = 0;	
        // ページを再読み込み後に表示
        if (isset($_COOKIE['product'])) {
        foreach ($_COOKIE['product'] as $name => $value) {
        	$objQuery = new SC_Query();
        		// DBから一覧表示用商品情報取得
        		$arrRet = $objQuery->select("*", "vw_products_allclass AS alldtl", "product_id =".$value);
        		$this->arrItemHistory[$cnt] = $arrRet[0];
        		$cnt = $cnt+1;
        }
    }
    //クッキーに重複項目がないか判定処理
    $duplicateFlg = true;
	    if (isset($_COOKIE['product'])) {
	    foreach ($_COOKIE['product'] as $name => $value) {
		    if($value == $_GET['product_id']){
			    $duplicateFlg = false;
		    }
	    }
    }
    //重複がない場合クッキーに設定
    if($duplicateFlg){
    if($cnt < 4){
    $cnt = $cnt + 1;
    setcookie("product[".$cnt."]", $_GET['product_id'],time()+60*60*24*30 );
    }
    else{
    $reNum = 1;
    foreach ($_COOKIE['product'] as $name => $value) {
    if($reNum > 1){
    $setNum = $reNum -1;
    setcookie("product[".$setNum."]", $value, time()+60*60*24*30 );
    }
    $reNum = $reNum + 1;
    }
    setcookie("product[4]", $_GET['product_id'], time()+60*60*24*30 );
    }
    }
    }

}
?>


data/Smarty/templates/default/detail.tpl

<!--▼閲覧履歴ここから-->
<!--{if $arrItemHistory}-->
<div id="whoboughtarea">
<h2><img src="<!--{$TPL_DIR}-->img/products/title_recommend.jpg" width="580" height="30" alt="閲覧履歴" /></h2>
<div class="whoboughtblock">

<!--{section name=cnt loop=$arrItemHistory}-->
<!--{if ($smarty.section.cnt.index % 2) == 0}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 左列 -->
<div class="whoboughtleft">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->

<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>

<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">
<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- 左列 -->

<!--{/if}-->

<!--{if ($smarty.section.cnt.index % 2) != 0}-->
<!--{* assign var=nextCnt value=$smarty.section.cnt.index+1 *}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 右列 -->
<div class="whoboughtright">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" />
</a>
<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>

<p>価格<span class="mini">(税込)</span>:<span class="price">

<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].comment|escape|nl2br}--></p>
</div>
<!-- 右列 -->
<!--{/if}-->
<!--{/if}-->


</div>
<!--{/if}-->
<!--{/section}-->

</div>
<!--{/if}-->


ご教授ください><


----------------
EC-CUBEバージョン 2.1.2
PHPバージョン PHP 4.3.9
DBバージョン MySQL 4.1.20

gizmo
投稿日時: 2009/2/26 15:35
対応状況: −−−
半人前
登録日: 2009/1/22
居住地:
投稿: 15
Re: 最近チェックした商品の履歴表示

閲覧履歴さっそく使わせていただきました。

右列が表示されなかった件ですが。
最初に紹介されているソースで問題ないようです。


data/Smarty/templates/default/detail.tpl

引用:

<!--▼閲覧履歴ここから-->
<!--{if $arrItemHistory}-->
<div id="whoboughtarea">
<h2>最近チェックした商品の履歴</h2>
<div class="whoboughtblock">
<!--{section name=cnt loop=$arrItemHistory}-->
<!--{if ($smarty.section.cnt.index % 2) == 0}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 左列 -->
<div class="whoboughtleft">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" /></a>
<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>
<p>価格<span class="mini">(税込)</span>:<span class="price">
<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].main_list_comment|escape|nl2br}--></p>
</div>
<!-- /左列 -->
<!--{/if}-->
<!--{/if}-->

<!--{if ($smarty.section.cnt.index % 2) != 0}-->
<!--{* assign var=nextCnt value=$smarty.section.cnt.index+1 *}-->
<!--{if $arrItemHistory[cnt].product_id}-->
<!-- 右列 -->
<div class="whoboughtright">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->">
<!--{if $arrItemHistory[cnt].main_list_image != ""}-->
<!--{assign var=image_path value="`$arrItemHistory[cnt].main_list_image`"}-->
<!--{else}-->
<!--{assign var=image_path value="`$smarty.const.NO_IMAGE_DIR`"}-->
<!--{/if}-->
<img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$image_path|sfRmDupSlash}-->&width=65&height=65" alt="<!--{$arrItemHistory[cnt].name|escape}-->" /></a>
<!--{assign var=price02_min value=`$arrItemHistory[cnt].price02_min`}-->
<!--{assign var=price02_max value=`$arrItemHistory[cnt].price02_max`}-->
<h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrItemHistory[cnt].product_id}-->"><!--{$arrItemHistory[cnt].name|escape}--></a></h3>
<p>価格<span class="mini">(税込)</span>:<span class="price">
<!--{if $price02_min == $price02_max}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円</span></p>
<p class="mini"><!--{$arrItemHistory[cnt].main_list_comment|escape|nl2br}--></p>
</div>
<!-- /右列 -->
<!--{/if}-->
<!--{/if}-->
<!--{/section}-->
</div>
</div>
<!--{/if}-->


上記に修正すると、正常に表示されました。

動作環境は、

2.2.0-beta
です。
leoism
投稿日時: 2009/3/2 14:43
対応状況: −−−
常連
登録日: 2008/8/26
居住地:
投稿: 60
Re: 最近チェックした商品の履歴表示
>tmtqn543様

商品一覧のファイル
LC_Page_Products_List.phpに、
SHIGEさんが提供してくださった
LC_Page_Products_Detail.phpにしたことと、
同じ修正を加えてやれば、商品一覧に追加した
ブロックからでも表示できるようになりましたよ。
tonton
投稿日時: 2009/3/3 13:24
対応状況: −−−
仙人
登録日: 2008/8/14
居住地:
投稿: 437
Re: 最近チェックした商品の履歴表示
私も、
LC_Page_Products_List.php

L82へ、
----------
//2008.04.11 商品閲覧履歴取得
$this->Get_ItemHistory();
----------

最後のL705
}
?>
の前へ、
----------
//2008.04.11 商品詳細閲覧履歴取得、表示データ取得処理
function Get_ItemHistory() {
$cnt = 0;
// ページを再読み込み後に表示
if (isset($_COOKIE['product'])) {
foreach ($_COOKIE['product'] as $name => $value) {
$objQuery = new SC_Query();
// DBから一覧表示用商品情報取得
$arrRet = $objQuery->select("*", "vw_products_allclass AS alldtl", "product_id =".$value);
$this->arrItemHistory[$cnt] = $arrRet[0];
$cnt = $cnt+1;
}
}

//クッキーに重複項目がないか判定処理
$duplicateFlg = true;
foreach ($_COOKIE['product'] as $name => $value) {
if($value == $_GET['product_id']){
$duplicateFlg = false;
}
}

//重複がない場合クッキーに設定
if($duplicateFlg){
if($cnt < 4){
$cnt = $cnt + 1;
setcookie("product[".$cnt."]", $_GET['product_id'],time()+60*60*24*30 );
}else{
$reNum = 1;
foreach ($_COOKIE['product'] as $name => $value) {
if($reNum > 1){
$setNum = $reNum -1;
setcookie("product[".$setNum."]", $value, time()+60*60*24*30 );
}
$reNum = $reNum + 1;
}
setcookie("product[4]", $_GET['product_id'], time()+60*60*24*30 );
}
}
}
----------
追加で一覧ページでも表示できるようになりました。
ありがとうございました。
arts
投稿日時: 2009/3/20 19:02
対応状況: −−−
長老
登録日: 2009/2/7
居住地:
投稿: 268
Re: 最近チェックした商品の履歴表示
このスレッドを読んで詳細ページへの表示はなんとか
できたのですが一覧ページでの表示がうまくいきません。
ECCUBE2.3.3です。
LC_Page_Products_List.phpの記述は下記のようにしました。
どのようにするとうまく表示されるようになるでしょうか?
どうぞよろしくお願い致します

WHERE category_id = ?", $arrCategory_id);
$arrSearch['category'] = $arrCat;
}

// 商品名検索条件
if ($_GET['name'] === "") {
$arrSearch['name'] = "指定なし";
}else{
$arrSearch['name'] = $_GET['name'];
}
}

// レイアウトデザインを取得
$layout = new SC_Helper_PageLayout_Ex();
$layout->sfGetPageLayout($this, false, "products/list.php");

if(isset($_POST['mode']) && $_POST['mode'] == "cart"
&& $_POST['product_id'] != "") {

// 値の正当性チェック
if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
} else {
// 入力値の変換
$this->arrErr = $this->lfCheckError($_POST['product_id']);
if(count($this->arrErr) == 0) {
$objCartSess = new SC_CartSession();
$classcategory_id = "classcategory_id". $_POST['product_id'];
$classcategory_id1 = $_POST[$classcategory_id. '_1'];
$classcategory_id2 = $_POST[$classcategory_id. '_2'];
$quantity = "quantity". $_POST['product_id'];
// 規格1が設定されていない場合
if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
$classcategory_id1 = '0';
}
// 規格2が設定されていない場合
if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
$classcategory_id2 = '0';
}
$objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
$objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
$this->sendRedirect($this->getLocation(URL_CART_TOP));
exit;
}
}
}

$this->tpl_subtitle = $tpl_subtitle;

// 支払方法の取得
$this->arrPayment = $this->lfGetPayment();
// 入力情報を渡す
$this->arrForm = $_POST;

$this->lfConvertParam();

$this->category_id = $arrCategory_id[0];
$this->arrSearch = $arrSearch;

$objView->assignobj($this);
$objView->display(SITE_FRAME);
}

/**
* モバイルページを初期化する.
*
* @return void
*/
function mobileInit() {
$this->init();
}

/**
* Page のプロセス(モバイル).
*
* FIXME スパゲッティ...
*
* @return void
*/
function mobileProcess() {
$objView = new SC_MobileView();
$conn = new SC_DBConn();
$objDb = new SC_Helper_DB_Ex();

//表示件数の選択
if(isset($_REQUEST['disp_number'])
&& SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {
$this->disp_number = $_REQUEST['disp_number'];
} else {
//最小表示件数を選択
$this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
}

//表示順序の保存
$this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";

// GETのカテゴリIDを元に正しいカテゴリIDを取得する。
$arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);


// タイトル編集
$tpl_subtitle = "";
$tpl_search_mode = false;

if (!isset($_GET['mode'])) $_GET['mode'] = "";
if (!isset($_POST['mode'])) $_POST['mode'] = "";
if (!isset($_GET['name'])) $_GET['name'] = "";
if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = "";
if (empty($arrCategory_id)) $arrCategory_id = array("0");

if($_GET['mode'] == 'search'){
$tpl_subtitle = "検索結果";
$tpl_search_mode = true;
}elseif (empty($arrCategory_id)) {
$tpl_subtitle = "全商品";
}else{
$arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
$tpl_subtitle = $arrFirstCat['name'];
}

$objQuery = new SC_Query();
$count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);

// 以下の条件でBEST商品を表示する
// ・BEST最大数の商品が登録されている。
// ・カテゴリIDがルートIDである。
// ・検索モードでない。
if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) {
// 商品TOPの表示処理

$this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
$this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
} else {
if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
// 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
$arrCategory_id = array("");
}

// 商品一覧の表示処理
$this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']);

// 検索条件を画面に表示
// カテゴリー検索条件
if (strlen($_GET['category_id']) == 0) {
$arrSearch['category'] = "指定なし";
}else{
$arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id));
$arrSearch['category'] = $arrCat;
}

// 商品名検索条件
if ($_GET['name'] === "") {
$arrSearch['name'] = "指定なし";
}else{
$arrSearch['name'] = $_GET['name'];
}
}

if($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
// 値の正当性チェック
if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
} else {
// 入力値の変換
$this->arrErr = $this->lfCheckError($_POST['product_id']);
if(count($this->arrErr) == 0) {
$objCartSess = new SC_CartSession();
$classcategory_id = "classcategory_id". $_POST['product_id'];
$classcategory_id1 = $_POST[$classcategory_id. '_1'];
$classcategory_id2 = $_POST[$classcategory_id. '_2'];
$quantity = "quantity". $_POST['product_id'];
// 規格1が設定されていない場合
if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
$classcategory_id1 = '0';
}
// 規格2が設定されていない場合
if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
$classcategory_id2 = '0';
}
$objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
$objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
$this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));
exit;
}
}
}


// ページ送り機能用のURLを作成する。
$objURL = new Net_URL($_SERVER['PHP_SELF']);
foreach ($_REQUEST as $key => $value) {
if ($key == session_name() || $key == 'pageno') {
continue;
}
$objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));
}

if ($this->objNavi->now_page > 1) {
$objURL->addQueryString('pageno', $this->objNavi->now_page - 1);
$this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
}
if ($this->objNavi->now_page < $this->objNavi->max_page) {
$objURL->addQueryString('pageno', $this->objNavi->now_page + 1);
$this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
}

$this->tpl_subtitle = $tpl_subtitle;
$this->tpl_search_mode = $tpl_search_mode;

// 支払方法の取得
$this->arrPayment = $this->lfGetPayment();
// 入力情報を渡す
$this->arrForm = $_POST;

$this->category_id = $arrCategory_id[0];
$this->arrSearch = $arrSearch;
$this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl";

$objView->assignobj($this);
$objView->display(SITE_FRAME);
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}

/* カテゴリIDがルートかどうかの判定 */
function lfIsRootCategory($category_id) {
$objQuery = new SC_Query();
$level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id));
if($level == 1) {
return true;
}
return false;
}

/* 商品一覧の表示 */
function lfDispProductsList($category_id, $name, $disp_num, $orderby) {

$objQuery = new SC_Query();
$objDb = new SC_Helper_DB_Ex();
$this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno'];

//表示順序
switch($orderby) {

//価格順
case 'price':
$col = "DISTINCT price02_min, product_id, product_code_min, product_code_max,"
. " name, comment1, comment2, comment3,"
. " main_list_comment, main_image, main_list_image,"
. " price01_min, price01_max, price02_max,"
. " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
. " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
. " status, product_flag, create_date, del_flg";
$from = "vw_products_allclass AS T1";
$order = "price02_min, product_id";
break;

//新着順
case 'date':
$col = "DISTINCT create_date, product_id, product_code_min, product_code_max,"
. " name, comment1, comment2, comment3,"
. " main_list_comment, main_image, main_list_image,"
. " price01_min, price01_max, price02_min, price02_max,"
. " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
. " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
. " status, product_flag, del_flg";
$from = "vw_products_allclass AS T1";
$order = "create_date DESC, product_id";
break;

default:
$col = "DISTINCT T1.product_id, product_code_min, product_code_max,"
. " price01_min, price01_max, price02_min, price02_max,"
. " stock_min, stock_max, stock_unlimited_min,"
. " stock_unlimited_max, del_flg, status, name, comment1,"
. " comment2, comment3, main_list_comment, main_image,"
. " main_list_image, product_flag, deliv_date_id, sale_limit,"
. " point_rate, sale_unlimited, create_date, deliv_fee, "
. " T4.product_rank, T4.category_rank";
$from = "vw_products_allclass AS T1"
. " JOIN ("
. " SELECT max(T3.rank) AS category_rank,"
. " max(T2.rank) AS product_rank,"
. " T2.product_id"
. " FROM dtb_product_categories T2"
. " JOIN dtb_category T3 USING (category_id)"
. " GROUP BY product_id) AS T4 USING (product_id)";
$order = "T4.category_rank DESC, T4.product_rank DESC";
break;
}

// 商品検索条件の作成(未削除、表示)
$where = "del_flg = 0 AND status = 1 ";
// カテゴリからのWHERE文字列取得
if ( $category_id ) {
list($tmp_where, $arrval) = $objDb->sfGetCatWhere($category_id);
if($tmp_where != "") {
$where.= " AND $tmp_where";
}
}

// 商品名をwhere文に
$name = ereg_replace(",", "", $name);// XXX
// 全角スペースを半角スペースに変換
$name = str_replace(' ', ' ', $name);
// スペースでキーワードを分割
$names = preg_split("/ +/", $name);
// 分割したキーワードを一つずつwhere文に追加
foreach ($names as $val) {
if ( strlen($val) > 0 ){
$where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) ";
$ret = SC_Utils_Ex::sfManualEscape($val);
$arrval[] = "%$ret%";
$arrval[] = "%$ret%";
}
}

if (empty($arrval)) {
$arrval = array();
}

// 行数の取得
$linemax = count($objQuery->getAll("SELECT DISTINCT product_id "
. "FROM vw_products_allclass AS allcls "
. (!empty($where) ? " WHERE " . $where
: ""), $arrval));

$this->tpl_linemax = $linemax; // 何件が該当しました。表示用

// ページ送りの取得
$this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);

$strnavi = $this->objNavi->strnavi;
$strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi);
// 表示文字列
$this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi;
$startno = $this->objNavi->start_row; // 開始行

// 取得範囲の指定(開始行番号、行数のセット)
$objQuery->setlimitoffset($disp_num, $startno);
// 表示順序
$objQuery->setorder($order);

// 検索結果の取得
$this->arrProducts = $objQuery->select($col, $from, $where, $arrval);

// 規格名一覧
$arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
// 規格分類名一覧
$arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
// 規格セレクトボックス設定
if($disp_num == 15) {
for($i = 0; $i < count($this->arrProducts); $i++) {
$this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
// 購入制限数を取得
$this->lfGetSaleLimit($this->arrProducts[$i]);
}
}
}

/* 規格セレクトボックスの作成 */
function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {

$classcat_find1 = false;
$classcat_find2 = false;
// 在庫ありの商品の有無
$stock_find = false;

// 商品規格情報の取得
$arrProductsClass = $this->lfGetProductsClass($product_id);

// 規格1クラス名の取得
$this->tpl_class_name1[$product_id] =
isset($arrClassName[$arrProductsClass[0]['class_id1']])
? $arrClassName[$arrProductsClass[0]['class_id1']]
: "";

// 規格2クラス名の取得
$this->tpl_class_name2[$product_id] =
isset($arrClassName[$arrProductsClass[0]['class_id2']])
? $arrClassName[$arrProductsClass[0]['class_id2']]
: "";

// すべての組み合わせ数
$count = count($arrProductsClass);

$classcat_id1 = "";

$arrSele = array();
$arrList = array();

$list_id = 0;
$arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
$arrVal[0] = "\tval". $product_id. "_0 = new Array(''";

for ($i = 0; $i < $count; $i++) {
// 在庫のチェック
if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
continue;
}

$stock_find = true;

// 規格1のセレクトボックス用
if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
$arrList[$list_id].=");\n";
$arrVal[$list_id].=");\n";
$classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
$arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
$list_id++;

$arrList[$list_id] = "";
$arrVal[$list_id] = "";
}

// 規格2のセレクトボックス用
$classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];

// セレクトボックス表示値
if($arrList[$list_id] == "") {
$arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
} else {
$arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
}

// セレクトボックスPOST値
if($arrVal[$list_id] == "") {
$arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
} else {
$arrVal[$list_id].= ", '".$classcat_id2."'";
}
}

$arrList[$list_id].=");\n";
$arrVal[$list_id].=");\n";

// 規格1
$this->arrClassCat1[$product_id] = $arrSele;

$lists = "\tlists".$product_id. " = new Array(";
$no = 0;
foreach($arrList as $val) {
$this->tpl_javascript.= $val;
if ($no != 0) {
$lists.= ",list". $product_id. "_". $no;
} else {
$lists.= "list". $product_id. "_". $no;
}
$no++;
}
$this->tpl_javascript.= $lists.");\n";

$vals = "\tvals".$product_id. " = new Array(";
$no = 0;
foreach($arrVal as $val) {
$this->tpl_javascript.= $val;
if ($no != 0) {
$vals.= ",val". $product_id. "_". $no;
} else {
$vals.= "val". $product_id. "_". $no;
}
$no++;
}
$this->tpl_javascript.= $vals.");\n";

// 選択されている規格2ID
$classcategory_id = "classcategory_id". $product_id;

$classcategory_id_2 = $classcategory_id . "_2";
if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";

$this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
. "'" . $classcategory_id_2 . "',"
. "'" . $product_id . "',"
. "'" . $_POST[$classcategory_id_2] ."'); ";

// 規格1が設定されている
if($arrProductsClass[0]['classcategory_id1'] != '0') {
$classcat_find1 = true;
}

// 規格2が設定されている
if($arrProductsClass[0]['classcategory_id2'] != '0') {
$classcat_find2 = true;
}

$this->tpl_classcat_find1[$product_id] = $classcat_find1;
$this->tpl_classcat_find2[$product_id] = $classcat_find2;
$this->tpl_stock_find[$product_id] = $stock_find;
}

/* 商品規格情報の取得 */
function lfGetProductsClass($product_id) {
$arrRet = array();
if(SC_Utils_Ex::sfIsInt($product_id)) {
// 商品規格取得
$objQuery = new SC_Query();
$col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
$table = "vw_product_class AS prdcls";
$where = "product_id = ?";
$objQuery->setorder("rank1 DESC, rank2 DESC");
$arrRet = $objQuery->select($col, $table, $where, array($product_id));
}
return $arrRet;
}

/* 入力内容のチェック */
function lfCheckError($id) {

// 入力データを渡す。
$objErr = new SC_CheckError();

$classcategory_id1 = "classcategory_id". $id. "_1";
$classcategory_id2 = "classcategory_id". $id. "_2";
$quantity = "quantity". $id;
// 複数項目チェック
if ($this->tpl_classcat_find1[$id]) {
$objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
}
if ($this->tpl_classcat_find2[$id]) {
$objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
}
$objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));

return $objErr->arrErr;
}

// 購入制限数の設定
function lfGetSaleLimit($product) {
//在庫が無限または購入制限値が設定値より大きい場合
if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
$this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
} else {
$this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
}
}

//支払方法の取得
//payment_id 1:代金引換 2:銀行振り込み 3:現金書留
function lfGetPayment() {
$objQuery = new SC_Query;
$col = "payment_id, rule, payment_method";
$from = "dtb_payment";
$where = "del_flg = 0";
$order = "payment_id";
$objQuery->setorder($order);
$arrRet = $objQuery->select($col, $from, $where);
return $arrRet;
}

function lfconvertParam () {
foreach ($this->arrForm as $key => $value) {
if (preg_match('/^quantity[0-9]+/', $key)) {
$this->arrForm[$key]
= htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE);
}
}
}
//2008.04.11 商品詳細閲覧履歴取得、表示データ取得処理
function Get_ItemHistory() {
$cnt = 0;
// ページを再読み込み後に表示
if (isset($_COOKIE['product'])) {
foreach ($_COOKIE['product'] as $name => $value) {
$objQuery = new SC_Query();
// DBから一覧表示用商品情報取得
$arrRet = $objQuery->select("*", "vw_products_allclass AS alldtl", "product_id =".$value);
$this->arrItemHistory[$cnt] = $arrRet[0];
$cnt = $cnt+1;
}
}

//クッキーに重複項目がないか判定処理
$duplicateFlg = true;
foreach ($_COOKIE['product'] as $name => $value) {
if($value == $_GET['product_id']){
$duplicateFlg = false;
}
}

//重複がない場合クッキーに設定
if($duplicateFlg){
if($cnt < 4){
$cnt = $cnt + 1;
setcookie("product[".$cnt."]", $_GET['product_id'],time()+60*60*24*30 );
}else{
$reNum = 1;
foreach ($_COOKIE['product'] as $name => $value) {
if($reNum > 1){
$setNum = $reNum -1;
setcookie("product[".$setNum."]", $value, time()+60*60*24*30 );
}
$reNum = $reNum + 1;
}
setcookie("product[4]", $_GET['product_id'], time()+60*60*24*30 );
}
}
}

}
?>
seasoft
投稿日時: 2009/3/20 21:11
対応状況: −−−
登録日: 2008/6/4
居住地:
投稿: 7367
Re: 最近チェックした商品の履歴表示
私は当該カスタマイズを試したことが無いので、具体的には分からないのですが、質問の中で気になりました点を。

> できたのですが一覧ページでの表示がうまくいきません。
> どのようにするとうまく表示されるようになるでしょうか?

この「うまく」とは、何かを具体的に書いておいたほうが、良いかと思います。
「表示がうまくいきません」ということですと、全く表示されなかったとも、乱れて表示されたとも解釈できますので。


----------------
Seasoft
こちらでの投稿は、アイディア程度に留めさせていただいております。
個別案件の作業は有償で承っております。お気軽にご相談ください。

arts
投稿日時: 2009/3/20 21:29
対応状況: −−−
長老
登録日: 2009/2/7
居住地:
投稿: 268
Re: 最近チェックした商品の履歴表示
レスありがとうございます。
上記の記述のままですと、商品一覧ページには
何の変化もありません。商品詳細ページでは
画面下部に履歴が表示されます。
商品一覧ページで、詳細ページのように表示されるには
どうしたら良いのかというのが質問になります。
一覧ページで表示に成功された方のレスを拝見して同じように
記述したつもりなのですが、何の変化もないのでどこか記述が
まちがっているのでしょうか。
« 1 2 3 (4) 5 6 »
| 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,847名です
総投稿数は109,986件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1291
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.