バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

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

フロント機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
metan
投稿日時: 2014/7/29 15:46
対応状況: −−−
一人前
登録日: 2013/3/4
居住地:
投稿: 112
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
sumida様

先ほど確認したのですが、一覧ページでレビューのある商品が20件あるのですが、

〇〇件のレビュー

上記の表示は始めの8件しか表示されないようです。

8件以降の商品は

件のレビュー

となっており、レビュー件数が取得できていないようです。

-追記-

調べましたところ、下記のプラグインが干渉しているようです。

http://www.ec-cube.net/products/detail.php?product_id=474

上記のプラグインでレビューのみ商品を表示した際に8件〜9件までした表示されませんでした。

これから、開発者の方に連絡を取ってみたいと思います。

sumida様

この度は、ご教授頂きまして誠にありがとうございました。希望の動作が出来て大変嬉しく思っております。


shutta様

ご教授頂きましたコードで上手くいきました。誠にありがとうございました。
shutta
投稿日時: 2014/7/29 15:27
対応状況: −−−
仙人
登録日: 2010/2/4
居住地: 関西
投稿: 835
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
引用:

重ねて質問で恐縮なのですが、レビューがある商品だけに

〇件のレビュー

の表示をしたいと考えているのですが、どのような記述を行えばよろしいのでしょうか?


list.tpl

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


赤字部分を追加するとか。


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

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

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

ご返信頂きまして誠にありがとうございます。

sumida様のご教授通りに行ったところ無事に表示されました!

本当にありがとうございます!

重ねて質問で恐縮なのですが、レビューがある商品だけに

〇件のレビュー

の表示をしたいと考えているのですが、どのような記述を行えばよろしいのでしょうか?
sumida
投稿日時: 2014/7/29 15:10
対応状況: −−−
仙人
登録日: 2013/2/10
居住地: 広島県呉市ときどき瀬戸内海
投稿: 641
Re: 商品一覧ページにレビュー件数を表示して該当の商品ページにリンクしたい
この部分は、引き継がれていないようです。
$arrProducts['productReviewCnt']

そこで、これでどうでしょう。
LC_Page_Products_List.php

        // 規格を設定
        $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;
    }

以下も追加

        // 商品ステータスを取得
        $this->productStatus = $this->arrProducts['productStatus'];
        unset($this->arrProducts['productStatus']);

// added
        $this->productReviewCnt = $this->arrProducts['productReviewCnt'];
        unset($this->arrProducts['productReviewCnt']);
// added


list.tplを以下に変更

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

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>

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

件のレビュー

のみの表示でリンクはされている状態です。
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 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>

そうすると

件のレビュー

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

レビュー件数の取得が出来ない様です。
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

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


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

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

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>

を追加いたしました。

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


(1) 2 »
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


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

統計情報

総メンバー数は88,873名です
総投稿数は110,000件です

投稿数ランキング

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
1295
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.