バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

質問 > フロント機能 > 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
metan
投稿日時: 2014/7/27 16:08
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
いつもお世話になっております。

商品一覧ページにレビューの件数を表示して該当の商品ページのレビューのエリアにリンクしたいと考えております。

一覧ページにて、レビューのある商品にだけ、レビュー数を表示して商品ページにリンク。

リンク先の例)
http://○○.com/products/detail○○.html#review_area

下記のページを参考にしましたが、うまくいきませんでした。
http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=13126&forum=10&post_id=60205

どなたかご教授いただけませんでしょうか?よろしくお願いいたします。

EC-CUBEバージョン 2.12.2
PHPバージョン PHP 5.3.3
DBバージョン MySQL 5.0.95
namahage
投稿日時: 2014/7/28 13:27
対応状況: −−−
長老
登録日: 2013/2/28
居住地: 大阪
投稿: 198
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
ども


どのようにうまくいかなかったのか教えてください。

レビューを出すことに失敗しているのか、
エラーがでている状態なのか、
リンク押下したけどレビューのところにページジャンプしてくれないのか

最初の質問で、現在の状況を具体的に記述するとレスがつきやすいです。
metan
投稿日時: 2014/7/28 16:20
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
namahage様

ご返信誠にありがとうございます。

また、説明不足のスレッド。お許しください。

以前に同じ件でスレッドを立てたのですが、そこでもうまくいきませんでした。

下記が以前のスレッドになります。

http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=14606&forum=10&post_id=65351#forumpost65351

上記スレッドよりtommy0714様から、プログラム的には問題ないとの事で頂いたのですが、テンプレートの記述位置が悪いのか、レビュー件数が表示されませんでした。

以上が現在までの詳細になります。

御手数お掛けしますがご教授頂けましたら幸いです。
sumida
投稿日時: 2014/7/28 21:59
対応状況: −−−
仙人
登録日: 2013/2/10
居住地: 広島県呉市ときどき瀬戸内海
投稿: 641
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
「プログラム的には問題ないとの事で頂いたのですが、テンプレートの記述位置が悪いのか」という疑問があるのであれば、
「どのようにコードを修正したのか」などの情報がないとわかりません。
metan
投稿日時: 2014/7/29 9:55
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
sumida様

ご返信頂きまして誠にありがとうございます。私の行った修正は

data/class/pages/products/LC_Page_Products_List.php

のファイルに

// 商品一覧データの取得
$arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData);
$this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition);
$urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";
// モバイルの場合に検索条件をURLの引数に追加
if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
$searchNameUrl = urlencode(mb_convert_encoding($this->arrSearchData['name'], 'SJIS-win', 'UTF-8'));
$urlParam .= "&mode={$this->mode}&name={$searchNameUrl}&orderby={$this->orderby}";
}
$this->objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, 'fnNaviPage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);
$this->arrProducts = $this->lfGetProductsList($arrSearchCondition, $this->disp_number, $this->objNavi->start_row, $this->tpl_linemax, $objProduct);

▼ここから追加▼
foreach($arrProductId as $product_id)
{
$arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
}
▲ここまで追加▲

上記コードを追加して、

data/Smarty/templates/XXX/products/list.tpl

のファイルの

<!--{assign var=id value=$arrProduct.product_id}-->

以降に

<a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->"><!--{$arrProducts.productReviewCnt[$id]}-->件のレビュー</a>

を追加いたしました。

ここまでで、システムのエラーなどは出なかったのですが、レビューの件数が表示されずにいました。


shutta
投稿日時: 2014/7/29 10:03
対応状況: −−−
仙人
登録日: 2010/2/4
居住地: 関西
投稿: 835
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
ぱっと見て、おやっと思っただけなので、外しているかもしれませんが、
$arrProductsとしないといけないところが、
$arrProductになっていて、末尾にsが足りていない部分があるように思います。
如何でしょうか?


----------------

リゾート会員権(エクシブ等)の売買・仲介

pineray
投稿日時: 2014/7/29 11:03
対応状況: −−−
長老
登録日: 2006/9/9
居住地: 伊賀
投稿: 292
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
引用:

metanさんは書きました:
▼ここから追加▼
foreach($arrProductId as $product_id)
{
$arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
}
▲ここまで追加▲

レビュー件数をセットしている上記の部分ですが、以下の様に変更してみてはいかがでしょうか。

$this->arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));


----------------
EC-CUBEのプラグインを公開しています!
いつも reCAPTCHA

metan
投稿日時: 2014/7/29 12:39
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
pineray様

ご返信頂きまして誠にありがとうございます。先ほど下記の記述致しました。

data/class/pages/products/LC_Page_Products_List.php

// 商品一覧データの取得
$arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData);
$this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition);
$urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";
// モバイルの場合に検索条件をURLの引数に追加
if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
$searchNameUrl = urlencode(mb_convert_encoding($this->arrSearchData['name'], 'SJIS-win', 'UTF-8'));
$urlParam .= "&mode={$this->mode}&name={$searchNameUrl}&orderby={$this->orderby}";
}
$this->objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, 'fnNaviPage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);
$this->arrProducts = $this->lfGetProductsList($arrSearchCondition, $this->disp_number, $this->objNavi->start_row, $this->tpl_linemax, $objProduct);

▼ここに追加▼
foreach($arrProductId as $product_id)
{
$this->arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
}
▲ここまで追加▲

switch ($this->getMode()) {

case 'json':
$this->doJson($objProduct);
break;

default:
$this->doDefault($objProduct);
break;
}

$this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3);


}



data/Smarty/templates/XXX/products/list.tpl

に下記のコードを追加いたしました。

<a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->"><!--{$arrProducts.productReviewCnt[$id]}-->件のレビュー</a>

そうすると

件のレビュー

のみの表示になります。リンクは該当の商品に正しくリンクされています。

レビュー件数の取得が出来ない様です。
sumida
投稿日時: 2014/7/29 13:16
対応状況: −−−
仙人
登録日: 2013/2/10
居住地: 広島県呉市ときどき瀬戸内海
投稿: 641
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
LC_Page_Products_List.php
に追加した

foreach($arrProductId as $product_id)
{
$arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
} 

がこの位置だと、$arrProductIdが未定ではないでしょうか。

なので、関数lfGetProductsList内にないといけないと思います。

        // 規格を設定
        $objProduct->setProductsClassByProductIds($arrProductId);
        $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);

// added
foreach($arrProductId as $product_id)
{
$arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
} 
// added

        return $arrProducts;
    }
metan
投稿日時: 2014/7/29 13:30
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
sumida様

ご返信頂きまして誠にありがとうございます。ご教授頂い通り下記の記述を致しました。

// 取得範囲の指定(開始行番号、行数のセット)
$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($arrProductId as $product_id)
{
$arrProducts['productReviewCnt'][$product_id] = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 AND product_id = ?", array($product_id));
}
// レビュー件数を取得


return $arrProducts;
}



data/Smarty/templates/〇〇/products/list.tpl

には

<a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.html"><!--{$arrProducts.productReviewCnt[$id]}-->件のレビュー</a>

上記コードを追加したのですが、

件のレビュー

のみの表示でリンクはされている状態です。
(1) 2 »
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


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

統計情報

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

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1567
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
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.