バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

質問 > フロント機能 > カテゴリーページの商品をさらにサブカテゴリごとで表示させたい

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
nikuudon
投稿日時: 2012/10/10 22:50
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
たびたびご質問です。

質問内容が重複しておりましたら、すいません。。
現在カテゴリーページは
デフォルトのままです。
それを下記の図のようにサブカテゴリーごとに分けたいのですが、

カテゴリーページ
---------------------
サブカテゴリ1タイトル
---------------------
サブカテゴリ1の商品1
サブカテゴリ1の商品2
サブカテゴリ1の商品3

---------------------
サブカテゴリ2タイトル
---------------------
サブカテゴリ2の商品1
サブカテゴリ2の商品2
サブカテゴリ2の商品3

どのようにカスタマイズすればよいのか
分からず、四苦八苦しております。
どなたか詳しい方がおられましたら、
お教えください。
よろしくお願い致します。


サーバー:エックスサーバー
----------------------------
[EC-CUBE] 2.11.1
[PHP] PHP 5.3.13
[データベース] MySQL 5.0.77
----------------------------
marugizmo
投稿日時: 2012/10/11 2:11
対応状況: −−−
一人前
登録日: 2012/4/6
居住地:
投稿: 147
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
こんばんは

ざっくりですが、LC_Page_Products_List.phpの商品データを取ってきているlfGetSearchConditionをカスタマイズして商品を商品自身のカテゴリ付きで取得、Smarty側でサブカテゴリごとに成形という流れだと思います。

もっとうまい方法があると思いますので、突っ込み大歓迎です。


----------------
Norihiro Maruoka
Wear Net

nikuudon
投稿日時: 2012/10/12 19:36
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
marugizmoさん

早速のご返事大変ありがとうございます。

色々とカスタマイズをこころ見たのですが、
うまくいきませんでした。
lfGetSearchConditionの部分をどのようにカスタマイズすればよろしいでしょうか??
下記がLC_Page_Products_List.phpのソースに
なります。

お手数おかけしてすいません。
よろしくお願い致します。

// {{{ requires
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* 商品一覧 のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Products_List.php 20764 2011-03-22 06:26:40Z nanasess $
*/
class LC_Page_Products_List extends LC_Page_Ex {

// {{{ properties

/** テンプレートクラス名1 */
var $tpl_class_name1 = array();

/** テンプレートクラス名2 */
var $tpl_class_name2 = array();

/** JavaScript テンプレート */
var $tpl_javascript;

var $orderby;

var $mode;

/** 検索条件(内部データ) */
var $arrSearchData = array();

/** 検索条件(表示用) */
var $arrSearch = array();

var $tpl_subtitle = '';

/** ランダム文字列 **/
var $tpl_rnd = '';

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();

$masterData = new SC_DB_MasterData_Ex();
$this->arrSTATUS = $masterData->getMasterData("mtb_status");
$this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
$this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
$this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max");
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {
parent::process();
$this->action();
$this->sendResponse();
}

/**
* Page のAction.
*
* @return void
*/
function action() {
$objQuery =& SC_Query_Ex::getSingletonInstance();
$objProduct = new SC_Product_Ex();

$this->arrForm = $_REQUEST;//時間が無いのでコレで勘弁してください。 tao_s
//modeの取得
$this->mode = $this->getMode();

//表示条件の取得
$this->arrSearchData = array(
'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])),
'maker_id' => intval($this->arrForm['maker_id']),
'name' => $this->arrForm['name']
);
$this->orderby = $this->arrForm['orderby'];

//ページング設定
$this->tpl_pageno = $this->arrForm['pageno'];
$this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']);

// 画面に表示するサブタイトルの設定
$this->tpl_subtitle = $this->lfGetPageTitle($this->mode, $this->arrSearchData['category_id']);

// 画面に表示する検索条件を設定
$this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData);

// 商品一覧データの取得
$arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData);
$this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition);
$urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";
$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);
//商品一覧の表示処理
$strnavi = $this->objNavi->strnavi;
// 表示文字列
$this->tpl_strnavi = empty($strnavi) ? " " : $strnavi;

// 規格1クラス名
$this->tpl_class_name1 = $objProduct->className1;

// 規格2クラス名
$this->tpl_class_name2 = $objProduct->className2;

// 規格1
$this->arrClassCat1 = $objProduct->classCats1;

// 規格1が設定されている
$this->tpl_classcat_find1 = $objProduct->classCat1_find;
// 規格2が設定されている
$this->tpl_classcat_find2 = $objProduct->classCat2_find;

$this->tpl_stock_find = $objProduct->stock_find;
$this->tpl_product_class_id = $objProduct->product_class_id;
$this->tpl_product_type = $objProduct->product_type;

// 商品ステータスを取得
$this->productStatus = $this->arrProducts['productStatus'];
unset($this->arrProducts['productStatus']);
$this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';';
//onloadスクリプトを設定
foreach ($this->arrProducts as $arrProduct) {
$js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});";
}

//カート処理
$target_product_id = intval($this->arrForm['product_id']);
if ( $target_product_id > 0) {
// 商品IDの正当性チェック
if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id'])
|| !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
}

// 入力内容のチェック
$arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
if (empty($arrErr)) {
$this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']);
SC_Response_Ex::sendRedirect(CART_URLPATH);
exit;
}
$js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id);
}

$this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
$this->tpl_onload .= 'fnOnLoad(); ';

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

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

/**
* カテゴリIDの取得
*
* @return integer カテゴリID
*/
function lfGetCategoryId($category_id) {

// 指定なしの場合、0 を返す
if (empty($category_id)) return 0;

// 正当性チェック
if (!SC_Utils_Ex::sfIsInt($category_id)
|| SC_Utils_Ex::sfIsZeroFilling($category_id)
|| !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0')
) {
SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
}

// 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。
$arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id);

if (empty($arrCategory_id)) {
SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
}

return $arrCategory_id[0];
}

/* 商品一覧の表示 */
function lfGetProductsList($searchCondition, $disp_number, $startno, $linemax, &$objProduct) {

$arrval_order = array();

$objQuery =& SC_Query_Ex::getSingletonInstance();
// 表示順序
switch ($this->orderby) {
// 販売価格が安い順
case 'price':
$objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
break;

// 新着順
case 'date':
$objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
break;

default:
if (strlen($searchCondition["where_category"]) >= 1) {
$dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE ".$searchCondition["where_category"].")";
$arrval_order = array_merge($searchCondition['arrvalCategory'], $searchCondition['arrvalCategory']);
} else {
$dtb_product_categories = 'dtb_product_categories';
}
$order = <<< __EOS__
(
SELECT
T3.rank
FROM
$dtb_product_categories T2
JOIN dtb_category T3
USING (category_id)
WHERE T2.product_id = alldtl.product_id
ORDER BY T3.rank DESC, T2.rank DESC
LIMIT 1
) DESC
,(
SELECT
T2.rank
FROM
$dtb_product_categories T2
JOIN dtb_category T3
USING (category_id)
WHERE T2.product_id = alldtl.product_id
ORDER BY T3.rank DESC, T2.rank DESC
LIMIT 1
) DESC
,product_id
__EOS__;
$objQuery->setOrder($order);
break;
}
// 取得範囲の指定(開始行番号、行数のセット)
$objQuery->setLimitOffset($disp_number, $startno);
$objQuery->setWhere($searchCondition['where']);

// 表示すべきIDとそのIDの並び順を一気に取得
$arrProduct_id = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrval_order));

// 取得した表示すべきIDだけを指定して情報を取得。
$where = "";
if (is_array($arrProduct_id) && !empty($arrProduct_id)) {
$where = 'product_id IN (' . implode(',', $arrProduct_id) . ')';
} else {
// 一致させない
$where = '0<>0';
}

$where .= ' AND del_flg = 0'; // 商品規格の削除フラグ
$objQuery =& SC_Query_Ex::getSingletonInstance();
$objQuery->setWhere($where);
$arrProducts = $objProduct->lists($objQuery, $arrProduct_id);

//取得している並び順で並び替え
$arrProducts2 = array();
foreach($arrProducts as $item) {
$arrProducts2[ $item['product_id'] ] = $item;
}
$arrProducts = array();
foreach($arrProduct_id as $product_id) {
$arrProducts[] = $arrProducts2[$product_id];
}

// 規格を設定
$objProduct->setProductsClassByProductIds($arrProduct_id);
$arrProducts += array('productStatus' => $objProduct->getProductStatus($arrProduct_id));
return $arrProducts;
}

/* 入力内容のチェック */
function lfCheckError($product_id, &$arrForm, $tpl_classcat_find1, $tpl_classcat_find2) {

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

// 複数項目チェック
if ($tpl_classcat_find1[$product_id]) {
$objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
}
if ($tpl_classcat_find2[$product_id]) {
$objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
}

$objErr->doFunc(array("商品規格ID", 'product_class_id', 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;
}

/**
* パラメータの読み込み
*
* @return void
*/
function lfGetDisplayNum($display_number) {
// 表示件数
return (SC_Utils_Ex::sfIsInt($display_number))
? $display_number
: current(array_keys($this->arrPRODUCTLISTMAX));
}

/**
* ページタイトルの設定
*
* @return str
*/
function lfGetPageTitle($mode, $category_id = 0){
if ($mode == 'search') {
return "検索結果";
} elseif ($category_id == 0) {
return "全商品";
} else {
$arrCat = SC_Helper_DB_Ex::sfGetCat($category_id);
return $arrCat['name'];
}
}

/**
* 表示用検索条件の設定
*
* @return array
*/
function lfGetSearchConditionDisp($arrSearchData){
$objQuery =& SC_Query_Ex::getSingletonInstance();
$arrSearch = array('category' => '指定なし', 'maker' => '指定なし', 'name' => '指定なし');
// カテゴリー検索条件
if ($arrSearchData['category_id'] > 0) {
$arrSearch['category'] = $objQuery->get('category_name', 'dtb_category', 'category_id = ?', array($arrSearchData['category_id']));
}

// メーカー検索条件
if (strlen($arrSearchData['maker_id']) > 0) {
$arrSearch['maker'] = $objQuery->get('name', 'dtb_maker', 'maker_id = ?', array($arrSearchData['maker_id']));
}

// 商品名検索条件
if (strlen($arrSearchData['name']) > 0) {
$arrSearch['name'] = $arrSearchData['name'];
}
return $arrSearch;
}

/**
* 該当件数の取得
*
* @return int
*/
function lfGetProductAllNum($searchCondition){
// 検索結果対象となる商品の数を取得
$objQuery =& SC_Query_Ex::getSingletonInstance();
$objQuery->setWhere($searchCondition['where']);
$objProduct = new SC_Product_Ex();
return $objProduct->findProductCount($objQuery, $searchCondition['arrval']);
}

/**
* 検索条件のwhere文とかを取得
*
* @return array
*/
function lfGetSearchCondition($arrSearchData){
$searchCondition = array(
'where' => "",
'arrval' => array(),
"where_category" => "",
'arrvalCategory' => array()
);

// カテゴリからのWHERE文字列取得
if ($arrSearchData["category_id"] != 0) {
list($searchCondition["where_category"], $searchCondition['arrvalCategory']) = SC_Helper_DB_Ex::sfGetCatWhere($arrSearchData["category_id"]);
}
// ▼対象商品IDの抽出
// 商品検索条件の作成(未削除、表示)
$searchCondition['where'] = "alldtl.del_flg = 0 AND alldtl.status = 1 ";

// 在庫無し商品の非表示
if (NOSTOCK_HIDDEN === true) {
$searchCondition['where'] .= ' AND (stock >= 1 OR stock_unlimited = 1)';
}

if (strlen($searchCondition["where_category"]) >= 1) {
$searchCondition['where'] .= " AND T2.".$searchCondition["where_category"];
$searchCondition['arrval'] = array_merge($searchCondition['arrval'], $searchCondition['arrvalCategory']);
}

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

// メーカーらのWHERE文字列取得
if ($arrSearchData['maker_id']) {
$searchCondition['where'] .= " AND alldtl.maker_id = ? ";
$searchCondition['arrval'][] = $arrSearchData['maker_id'];
}
return $searchCondition;
}

/**
* カートに入れる商品情報にエラーがあったら戻す
*
* @return str
*/
function lfSetSelectedData(&$arrProducts, $arrForm, $arrErr, $product_id){
$js_fnOnLoad = "";
foreach (array_keys($arrProducts) as $key) {
if ($arrProducts[$key]['product_id'] == $product_id) {

$arrProducts[$key]['product_class_id'] = $arrForm['product_class_id'];
$arrProducts[$key]['classcategory_id1'] = $arrForm['classcategory_id1'];
$arrProducts[$key]['classcategory_id2'] = $arrForm['classcategory_id2'];
$arrProducts[$key]['quantity'] = $arrForm['quantity'];
$arrProducts[$key]['arrErr'] = $arrErr;
$js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProducts[$key]['product_id']}, '{$arrForm['classcategory_id2']}');";
}
}
return $js_fnOnLoad;
}

/**
* カートに商品を追加
*
* @return void
*/
function lfAddCart($arrForm, $referer){
$product_class_id = $arrForm['product_class_id'];
$objCartSess = new SC_CartSession_Ex();
$objCartSess->addProduct($product_class_id, $arrForm['quantity']);

// カート「戻るボタン」用に保持
if (SC_Utils_Ex::sfIsInternalDomain($referer)) {
//該当メソッドが無いため、$_SESSIONに直接セット
$_SESSION['cart_referer_url'] = $referer;
}
}
}
?>
nikuudon
投稿日時: 2012/10/15 21:37
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
こちらのサイトを参考に
http://ec-cube.nakweb.com/blog/827.html

すれば出来るかなと思い、下記を挿入したところ
エラーが起きました。。
// サブカテゴリリストを取得
$this->arrSubCatList = $this->getSubCatList($this->arrSearchData['category_id']);

使用バージョンが2.11.2になっておりましたが、
2.11.1では出来ないのでしょうか?
また、参考URLを参考にすれば、
質問内容のように表示されますでしょうか?
すいません、どうかお教えください。

下記はエラー内容になります

Fatal error: Call to undefined method LC_Page_Products_List_Ex::getSubCatList() in /home/○○○/public_html/shop/data/class/pages/products/LC_Page_Products_List.php on line 132
nikuudon
投稿日時: 2012/10/16 23:46
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
こちらのサイトを参考に
http://ec-cube.nakweb.com/blog/827.html

カテゴリーページの商品をサブカテゴリごとで表示させたいため、
ec-cubeのバージョンを2.11.1から2.11.2にバージョンアップしたいと考えております。
どのような手順でバージョンアップすればよろしいでしょうか?
また、2.11.1でもサブカテゴリごとに表示可能であれば
お手数お掛けしますが、お教えください

よろしくお願い致します。
marugizmo
投稿日時: 2012/10/17 12:50
対応状況: −−−
一人前
登録日: 2012/4/6
居住地:
投稿: 147
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
こんにちは

http://ec-cube.nakweb.com/blog/827.htmlにも書かれてますが、getSubCatListに$parent_category_idを与えても、全カテゴリしか出てきません。

どうもちょうど良いのがないので書いてみました。


// 選択中のカテゴリ
$cat_temp = $this->lfGetCategoryId(intval($this->arrForm['category_id']));

$arrCategory_id$objQuery =& SC_Query_Ex::getSingletonInstance();
$arrCategory_id$col = '';
$arrCategory_id$col .= ' cat.category_id,';
$arrCategory_id$col .= ' cat.category_name,';
$arrCategory_id$col .= ' cat.parent_category_id,';
$arrCategory_id$col .= ' cat.level,';
$arrCategory_id$col .= ' cat.rank';
$arrCategory_id$from = 'dtb_category as cat';
$arrCategory_id$objQuery->setOption('ORDER BY level DESC');

// カテゴリ一覧配列
$arrRet = $objQuery->select($col, $from, $where);

// 結果を格納する配列を用意
$child_cat_list = array();
// 関数呼び出し
$this->search_and_push_cat($arrRet, $child_cat_list, $cat_temp);

// 子カテゴリ抽出関数
function search_and_push_cat(&$arg1, &$arg2, $arg3) {
    for ($i = 0; $i < count($arg1); $i++) {
        $val = $arg1[$i];
        if ($val["parent_category_id"] <> $arg3) { continue; }
        array_push($arg2, $val);
        $this->search_and_push_cat($arg1, $arg2, $val["category_id"]);
    }
}


$child_cat_listでサブカテゴリの配列が取れます。

泥臭いですが、LC_Page_Products_Listの中でそれぞれのカテゴリーごとに$this->arrProductsのカテゴリidがマッチする商品を取り出すという方法になると思います。


----------------
Norihiro Maruoka
Wear Net

nikuudon
投稿日時: 2012/10/17 18:49
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
marugizmoさま

ご対応頂き大変ありがとうございます!
早速LC_Page_Products_List.phpにソースコードを反映させたのですが、212行目の上に
↓ココ↓

// 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。
$arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id);

if (empty($arrCategory_id)) {
SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
}

return $arrCategory_id[0];
}

$arrCategory_id$objQuery =& SC_Query_Ex::getSingletonInstance();
$arrCategory_id$col = '';
$arrCategory_id$col .= ' cat.category_id,';
$arrCategory_id$col .= ' cat.category_name,';
$arrCategory_id$col .= ' cat.parent_category_id,';
$arrCategory_id$col .= ' cat.level,';
$arrCategory_id$col .= ' cat.rank';
$arrCategory_id$from = 'dtb_category as cat';
$arrCategory_id$objQuery->setOption('ORDER BY level DESC');

を追加したら
Parse error: syntax error, unexpected T_VARIABLE in …
/LC_Page_Products_List.php on line 212と
エラーが出ました。。

どの部分あたりにソースを入れればよろしいでしょうか?
お手数お掛けして、すいません。
よろしくお願い致します
marugizmo
投稿日時: 2012/10/17 19:30
対応状況: −−−
一人前
登録日: 2012/4/6
居住地:
投稿: 147
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
こんにちは

オリジナル2.12のLC_Page_Products_List.phpでは212行目はaction()の終了後となります。

私が書いた分で言うと

// 選択中のカテゴリ
$cat_temp = $this->lfGetCategoryId(intval($this->arrForm['category_id']));
  ・
  ・
  ・
// 関数呼び出し
$this->search_and_push_cat($arrRet, $child_cat_list, $cat_temp);

の部分は
action()の中に入れていただかないと動きません。

function search_and_push_cat()はファンクションなので、class LC_Page_Products_List extends LC_Page_Exの中にあれば大丈夫です。

EC-CUBEの挙動についてご理解いただいた上で作業していただく必要があります。

http://svn.ec-cube.net/open_trac/wiki/EC-CUBE%E6%A8%99%E6%BA%96%E8%A6%8F%E7%B4%84

http://svn.ec-cube.net/open_trac/wiki/EC-CUBE%E6%A8%99%E6%BA%96%E8%A6%8F%E7%B4%84/%E3%83%AA%E3%83%95%E3%82%A1%E3%82%AF%E3%82%BF%E3%83%AA%E3%83%B3%E3%82%B0%E3%82%AC%E3%82%A4%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3

ご理解いただいた上で作業されている場合はすいません。


----------------
Norihiro Maruoka
Wear Net

nikuudon
投稿日時: 2012/10/17 23:17
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
marugizmoさま

すみません。。
EC-CUBEの挙動についてご理解のしていたつもりでしたのですが、
まだまだphpの勉強不足で分かっていないことだらけでした。

これからさらに知識と技術の向上を励んでいきます。
ご指摘頂きありがとうございます。

エラーの件について、
action関数の中に
/ 選択中のカテゴリ
$cat_temp = $this->lfGetCategoryId(intval($this->arrForm['category_id']));
  ・
  ・
// 関数呼び出し
$this->search_and_push_cat($arrRet, $child_cat_list, $cat_temp);

を入れたのですが、
Parse error: syntax error, unexpected T_VARIABLE
とエラーが表示されてしまいます。

どこの部分に入れればいいのか、もしよろしければ
お教えください。
お手数お掛けします。。

下記がaction関数の部分のコードになります。

function action() {
$objQuery =& SC_Query_Ex::getSingletonInstance();
$objProduct = new SC_Product_Ex();

$this->arrForm = $_REQUEST;//時間が無いのでコレで勘弁してください。 tao_s
//modeの取得
$this->mode = $this->getMode();

//表示条件の取得
$this->arrSearchData = array(
'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])),
'maker_id' => intval($this->arrForm['maker_id']),
'name' => $this->arrForm['name']
);
$this->orderby = $this->arrForm['orderby'];

//ページング設定
$this->tpl_pageno = $this->arrForm['pageno'];
$this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']);

// 画面に表示するサブタイトルの設定
$this->tpl_subtitle = $this->lfGetPageTitle($this->mode, $this->arrSearchData['category_id']);

// 画面に表示する検索条件を設定
$this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData);

// 商品一覧データの取得
$arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData);
$this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition);
$urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";
$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);
//商品一覧の表示処理
$strnavi = $this->objNavi->strnavi;
// 表示文字列
$this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi;

// 規格1クラス名
$this->tpl_class_name1 = $objProduct->className1;

// 規格2クラス名
$this->tpl_class_name2 = $objProduct->className2;

// 規格1
$this->arrClassCat1 = $objProduct->classCats1;

// 規格1が設定されている
$this->tpl_classcat_find1 = $objProduct->classCat1_find;
// 規格2が設定されている
$this->tpl_classcat_find2 = $objProduct->classCat2_find;

$this->tpl_stock_find = $objProduct->stock_find;
$this->tpl_product_class_id = $objProduct->product_class_id;
$this->tpl_product_type = $objProduct->product_type;

// 商品ステータスを取得
$this->productStatus = $this->arrProducts['productStatus'];
unset($this->arrProducts['productStatus']);
$this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';';
//onloadスクリプトを設定
foreach ($this->arrProducts as $arrProduct) {
$js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});";
}

//カート処理
$target_product_id = intval($this->arrForm['product_id']);
if ( $target_product_id > 0) {
// 商品IDの正当性チェック
if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id'])
|| !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
}

// 入力内容のチェック
$arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
if (empty($arrErr)) {
$this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']);
SC_Response_Ex::sendRedirect(CART_URLPATH);
exit;
}
$js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id);
}

$this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
$this->tpl_onload .= 'fnOnLoad(); ';

$this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3);
}
nikuudon
投稿日時: 2012/10/28 16:14
対応状況: −−−
常連
登録日: 2012/7/2
居住地:
投稿: 61
Re: カテゴリーページの商品をさらにサブカテゴリごとで表示させたい
色々と試してみたのですが、
なぜか、エラーが表示されてしまいます。。

下記URLを参考に
http://ec-cube.nakweb.com/blog/1708.html
2.11.1→2.11.2にバージョンアップしようと思うのですが、
2.11.1→2.11.2にバージョンアップするには
どのような方法で行えばよろしいでしょうか?

詳しい方がおられましたら、お教え下さい。
よろしくお願い致します。

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


 



ログイン


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

統計情報

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

投稿数ランキング

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