Blog

EC-CUBE2.11.0で商品情報の項目を増やす方法

2011年3月26日

EC-CUBE2.11.0で商品情報の項目を増やす方法をご紹介します。

例として商品詳細ページの上部にHTMLを入れるエリアを追加する方法をご紹介します。

この記事の内容

1. データベースにカラムを追加

ALTER TABLE dtb_products ADD COLUMN htmlcomment1 text;

2. 商品詳細ページのテンプレートにタグを追加

●data/Smarty/templates/default/detail.tpl

任意の場所にタグを追加

<!--{$arrProduct.htmlcomment1}-->

3. 管理画面の商品登録ページの編集

●data/Smarty/templates/admin/products/product.tpl

管理画面の商品入力画面の任意の場所に入力項目の行を追加

<tr>
           <td>詳細-上部デザイン</td>
           <td>
               <span class="attention"><!--{$arrErr.htmlcomment1}--></span>
               <textarea name="htmlcomment1" value="<!--{$arrForm.htmlcomment1|h}-->" maxlength="<!--{$smarty.const.LLTEXT_LEN}-->" style="<!--{if $arrErr.htmlcomment1 != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}--><!--{/if}-->"  cols="60" rows="8" class="area60"><!--{$arrForm.htmlcomment1|h}--></textarea><br />
               <span class="attention"> (上限<!--{$smarty.const.LLTEXT_LEN}-->文字)</span>
           </td>
</tr>

●data/Smarty/templates/admin/products/confirm.tpl

管理画面の商品入力確認画面の任意の場所に確認項目の行を追加

<tr>
           <th>詳細-上部デザイン</th>
           <td>
           <!--{$arrForm.htmlcomment1|nl2br_html}-->
           </td>
</tr>

4. Classファイルを変更する

●data/class/pages/admin/products/LC_Page_Admin_Products_Product.php

339行目あたりにエラー構文の追加 

$objFormParam->addParam(" 詳細-上部HTML", "htmlcomment1", LLTEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));

962行目あたりのArrayに

htmlcomment1

を追加

974行目あたりのInsertデータを生成している個所に

$sqlval['htmlcomment1'] = $arrList['htmlcomment1'];

を追加

●data/class/SC_Product.php

151行目あたり

,htmlcomment1

を追加

636行目あたり

dtb_products.htmlcomment1

を追加

以上で完了となります。