新年明けましておめでとうございます!
今年はプログラミングの技術を磨いて、もっとEC-CUBE本体にコミットをしていけたらいいなーと思っています。
よろしくお願いします。
さて先日、メーカー登録機能について書いてから、EC-CUBEのメーカー仕様について、うつらうつらと考えていました。
今回はその中で、「メーカー一覧ブロックがあれば便利でね?」とのことでやってみました。

PC版のみです。バグあったらご指摘を。
1.html/frontparts/bloc/maker.php を新規作成
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// {{{ requires
require_once realpath(dirname(__FILE__)) . '/../../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker_Ex.php';
// }}}
// {{{ generate page
$objPage = new LC_Page_FrontParts_BLoc_Maker_Ex();
$objPage->blocItems = $params['items'];
register_shutdown_function(array($objPage, "destroy"));
$objPage->init();
$objPage->process();
?>
2.data/class_extends/page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker_Ex.php を作成
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker.php';
/**
* メーカー のページクラス(拡張).
*
* LC_Page_FrontParts_Bloc_Maker をカスタマイズする場合はこのクラスを編集する.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_FrontParts_Bloc_Maker_Ex.php 2012-01-01 08:55:00 fukap $
*/
class LC_Page_FrontParts_Bloc_Maker_Ex extends LC_Page_FrontParts_Bloc_Maker {
// }}}
// {{{ functions
/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
}
/**
* Page のプロセス.
*
* @return void
*/
function process() {
parent::process();
}
/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}
}
?>
3.data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker.php を新規作成
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php';
/**
* メーカー のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_FrontParts_Bloc_Maker.php 2012-01-01 08:55:00 fukap $
*/
class LC_Page_FrontParts_Bloc_Maker extends LC_Page_FrontParts_Bloc {
// }}}
// {{{ functions
/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
}
/**
* Page のプロセス.
*
* @return void
*/
function process() {
$this->action();
$this->sendResponse();
}
/**
* Page のアクション.
*
* @return void
*/
function action() {
// メーカーを取得
$this->arrMakers = $this->lfGetMakers();
}
/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}
/**
* メーカー一覧を取得する
*
* @param
* @return array メーカー一覧の二次元配列
*/
function lfGetMakers(){
$objQuery =& SC_Query_Ex::getSingletonInstance();
$col = 'maker_id, name';
$where = 'del_flg = 0';
$from = 'dtb_maker';
$objQuery->setOrder('rank desc');
return $objQuery->select($col, $from, $where);
}
}
?>
4.data/Smarty/templates/default/frontparts/bloc/maker.tpl を新規作成
<!--{*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* This program is free software; you can redistribute it and/or
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*}-->
<style type="text/css">
div#maker_area h2 {
background-color:#de5e17;
text-align:center;
color:#fff;
padding:7px 0 7px 0;
}
</style>
<!--{if count($arrMakers) > 0}-->
<div class="bloc_outer clearfix">
<div id="maker_area">
<h2>メーカー一覧</h2>
<div class="bloc_body clearfix">
<ul>
<!--{foreach from=$arrMakers item=arrMaker}-->
<li>
<a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?transactionid=<!--{$transactionid}-->&mode=search&maker_id=<!--{$arrMaker.maker_id|u}-->">
<!--{$arrMaker.name|h}-->
</a>
</li>
<!--{/foreach}-->
</ul>
</div>
</div>
</div>
<!--{/if}-->
5.データベースの dtb_bloc に新規ブロックの情報を登録する
insert into dtb_bloc values(10,10,'メーカー','maker.tpl','maker','now()','now()','frontparts/bloc/maker.php',0);
6.管理画面>デザイン管理>PC>レイアウト設定で、未使用ブロックに「メーカー」ができているのを確認し、
トップページの適当な場所に配置する。
前にも書きましたが、メーカー登録機能はEC-CUBE2.11ではとても中途半端な仕様でもったいないです。
今後、本体標準機能として提供し続けるのか、プラグイン提供に切り分けるのかは議論すべきだろうと思いますが、
メーカー登録を実装するなら、メーカー登録可能項目を拡充し、メーカー一覧ブロックやメーカー一覧ページは備えていた方がいいと思います。
個人的には、プラグイン機能がうまく働くなら、プラグイン提供が良いと思います。












ピンバック: EC-CUBE NEWS | EC-CUBEに関するニュースやブログの最新情報をお届けします
現在2.11.4、で構築中ですが、上記の方法で試してみまいたが、未使用ブロックに「メーカー」ができていませんでした。
phppgadminを使用しているのでがデータベースの dtb_bloc の記載の場所が違うのでしょうか。
お手数ですが教えていただけると幸いです。
phpPgAdmin で dtb_bloc の中を覗いてみて、挿入したレコードのキーが重複していないか確認してみてください。
最初の値がdevice_type_id、次の値がbloc_id だったと思います。
その2つがキーになりますので、重複したレコードがあると、ブロックが表示されないと思います。
早速のご返信ありがとうございます。確認したところ重複されておりません。画像を送ることは可能でしょうか?
申し訳ございませんが、個別対応は有償にて承っております。
ご自身で対処いただきますよう、お願いいたします。
了解しました。ブロックが出ない理由は他にも考えられそうでしたら、最後にご教授いただけたら幸いです。現在ロンドン在住のため、電話でおききすることができないので、本当にすみません。
初めまして
メーカー別一覧メニューを作りたくて、あちらこちらを探していてこちらにたどりつきました
順番にファイルを作成していくだけで、とてもわかりやくく、思うようなものを作ることができました!
ありがとうございます!!!
※2.11.4です
他のページ参考にして、めっちゃ悩んでた時、
このページを発見しました。
ほんっと助かりました。
ただただ、ただただ感謝感激です。
大変参考になり助かりました。ありがとうございました。