バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

質問 > フロント機能 > 商品一覧を子カテゴリ別に表示させたい

フロント機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
AMUAMU
投稿日時: 2010/1/14 21:39
対応状況: −−−
登録日: 2009/5/2
居住地: 東京都
投稿: 2712
Re: 商品一覧を子カテゴリ別に表示させたい
まずはデータは期待通りにデータが取り出せていてSmartyに渡せているか確認しましょう。デバッグ出力を入れてみて変数の内容を確認したら良いと思います。
斜め読みですがテンプレートの使い方も怪しそうですが、テンプレートの使い方はSmartyマニュアルを参照して確認されるのが良いと思います。


----------------
EC-CUBE公式エヴァンジェリスト
EC-CUBEインテグレートパートナー (株)スピリット・オブ
移転・拡張・高速化・問題解決
各種カスタマイズ・支援依頼承ります。

[url=h

NADEMO
投稿日時: 2010/1/13 9:46
対応状況: −−−
常連
登録日: 2009/10/5
居住地: 品川
投稿: 50
商品一覧を子カテゴリ別に表示させたい
お世話になります。
商品一覧を子カテゴリ別に表示したく、現在奮闘中です。

既存のHPは、こちらのページのように価格順、新着順に表示でき、
ページリンクと商品数が掲載されています。

このページを各ページへジャンプするリンクを残し、並びは子カテゴリ別にしたいのです。

homan様にご教授頂き、テストページ(上記表示形式ではなく、単純に商品一覧のみ)では子カテゴリ別に表示することはできました。(このとき、各ページへのリンクは貼っていません)
しかし、本ページでは上手く表示されませんでした。
下記に操作手順を掲載しますので、ヒントを頂ければと思います。
ご協力お願いいたします。

?LC_Page_Products_List.phpを変更する
・価格順、新着順の構文を削除
//価格順
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;

・「IfDispProductsList」関数のorderbyのswitch文defaultのところ
"T4.product_rank, T4.category_rank";を
"T4.product_rank, T4.category_rank, category_id";に変更

・「// 検索結果の取得」の下に下記を挿入(homan様から教えていただいたとおりに載せます)
// --------------------------------------
$this->arrCat = array();
$catTmp = "";

$j = -1;
for($i=0; $i < count($this->arrProducts); $i++) {
// カテゴリIDの保存
if (empty($catTmp) || $catTmp != $this->arrProducts[$i]['category_id']) {
$j++;
// 検索結果のカテゴリIDをすべて取得して、配列にする
$this->arrCat[$j][$this->arrProducts[$i]['category_id']] += 1;
$catTmp = $this->arrProducts[$i]['category_id'];
//$this->arrProductsCat[$j]['category_id'] = $catTmp;
}
$this->arrProductsCat[$j][] = $this->arrProducts[$i];
}

// カテゴリ名取得
foreach ($this->arrCat AS $key => $val) {
foreach ($val AS $key2 => $val2) {
$cat_sql = "SELECT category_name, category_info FROM
dtb_category WHERE category_id = ? ORDER BY rank DESC";
$tmpCat = $objQuery->getall($cat_sql, array($key2));
$this->arrCat[$key] = $tmpCat[0]['category_name'];
$this->arrCatInfo[$key] = $tmpCat[0]['category_info'];
}
}

// ------------------------------------------

私の既存ページではデータベースを触れないので、
(前の担当者がfrmファイルでサーバーへアップしていて、どう変更してよいかわかりません・・・)
category_infoカラムを追加できていないので、「category_info」の構文を削除しました。

?List.tplを変更する
既存ページでは商品を3つずつでループさせています。
なので、
<!--{section name=cnt loop=$arrProductsCat[cntx] step=3}-->
<!-- ▼1つめの商品 -->
<!--{assign var=id value=$arrProductsCat[cntx][cnt].product_id}-->

<div class="item-box-wrap">

<!--商品写真-->
<div class="item-box-photo">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrProductsCat[cntx][cnt].product_id}-->"><img src="<!--{$smarty.const.IMAGE_SAVE_URL|sfTrimURL}-->/<!--{$arrProductsCat[cntx][cnt].main_list_image}-->" alt="<!--{$arrProductsCat[cntx][cnt].name|escape}-->" /></a>
</div>

<!--商品名-->
<h3>
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrProductsCat[cntx][cnt].product_id}-->"><!--{$arrProductsCat[cntx][cnt].name|escape}--></a>
</h3>

<!--商品価格-->
<div class="item-box-price">
<!--{if $arrProductsCat[cntx][cnt].price02_min == $arrProductsCat[cntx][cnt].price02_max}-->
<!--{$arrProductsCat[cntx][cnt].price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{else}-->
<!--{$arrProductsCat[cntx][cnt].price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->〜<!--{$arrProductsCat[cntx][cnt].price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
<!--{/if}-->円
</div>

<!--売り切れの場合-->
<!--{if $arrProductsCat[cntx][cnt].stock_max == 0 && $arrProductsCat[cntx][cnt].stock_unlimited_max != 1}-->
<div class="item-box-soldout">
只今品切れ中です。
</div>
<!--{/if}-->

<!--商品コメント-->
<div class="item-box-comment">
<!--{$arrProductsCat[cntx][cnt].main_list_comment|escape|nl2br}-->
</div>
<div id="item-box-bt">
<a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrProductsCat[cntx][cnt].product_id}-->"><img src="<!--{$TPL_DIR}-->img/products/go_detail.gif"></a></div>

</div>
<!-- ▲1つめの商品 -->

という構文を<!-- ▼2つめの商品 -->の時は[cntx][$cnt3],<!-- ▼3つめの商品 -->の時は[cntx][$cnt2]に変えて書き加えました。

<!--{/section}-->
<!-- ▲商品ここまで -->
<!--{/section}-->

この前後に
<div id="undercolumn">
<ul class="pagenumberarea">
<li class="center"><!--{$tpl_strnavi}--></li>
</ul>
を加えてみたのですが、
商品の並び順が壊れてしまいます。
同じ商品がいくつも並んでしまいます。

たくさん直すところはあると思います。
是非ご指摘頂けませんでしょうか。
煮詰まってしまい、おかしなところが見つけられずにいます。

未熟な間違いも多いかと思いますが、一つずつ勉強します。
よろしくお願いします。


----------------
ホームページ作成は全てが始めてです。
プロの皆様のお力をお借りしたいです。
宜しくお願いします。

スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


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

統計情報

総メンバー数は89,364名です
総投稿数は110,082件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1652
8
red
1570
9
mcontact
1304
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.