[EC-CUBE]ログイン後に見た商品の履歴を表示する

「[EC-CUBE]ログイン後に見た商品の履歴を表示する」の編集履歴(バックアップ)一覧はこちら

[EC-CUBE]ログイン後に見た商品の履歴を表示する - (2009/05/01 (金) 16:05:26) の最新版との変更点

追加された行は緑色になります。

削除された行は赤色になります。

ログイン後に「商品詳細」まで見た商品の履歴をブロック内に表示する。 クッキーに保持する。 履歴は1か月保持。 4件まで表示可能。 Cookieを削除されたらそれまで。。。 * 閲覧履歴情報を取得する /data/class/pages/products/LC_Page_Products_Detail.php に以下を追加。 #highlight(linenumber,php){{ }}
ログイン後に「商品詳細」まで見た商品の履歴をブロック内に表示する。 クッキーに保持する。 履歴は1か月保持。 4件まで表示可能。 Cookieを削除されたらそれまで。。。 * 閲覧履歴情報を取得する /data/class/pages/products/LC_Page_Products_Detail.php に以下を追加。 function proccess()内に以下を追加。 #highlight(linenumber,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();     // ここ追加から追加。 // 2009.05.01 商品詳細閲覧履歴処理 追加 $this->Get_ItemHistory(); // 追加ここまで。 }} ファイルの最後にfunctionを追加。 #highlight(linenumber,php){{ /** * 商品詳細閲覧履歴情報取得、表示データ取得 * 2009.05.01 追加 * @author y-nakajima */ 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; } } // Cookieに重複しているデータがないか判定 $duplicateFlg = true; foreach($_COOKIE['product'] as $name => $value){ if($value == $_GET['product_id']){ $duplicateFlg = false; } } // 重複していない場合、Cookieに保存 if($duplicateFlg){ // 4件以下だったら 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/Smqrty/templates/default/detail.tpl とりあえず、ファイルの最後の</div><!--▲CONTENTS-->の前に追加してみました。 #highlight(linenumber,php){{ <!--▼閲覧履歴ここから 2009.05.01--> <!--{if $arrItemHistory}--> <div id="whoboughtarea"> <h2><img src="<!--{$TPL_DIR}-->img/products/title_product_history.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}--> <!--▲閲覧履歴ここまで 2009.05.01--> </div> <!--▲CONTENTS--> }} * カスタマイズ結果 こーんな感じになりました。 商品詳細まで見た商品しか表示されないので。あしからず。 #ref(product_history.JPG)

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。