EC-CUBEの小技:商品一覧ページにサブ画像を表示【Ver.2.11.5】
この記事は最終更新日から1年以上が経過しています。
2ファイル変更
参考記述:[EC-CUBE 2.11.4] 商品一覧ページに商品サブ画像を表示したい | NAKWEB × EC-CUBE
/data/class_extends/SC_Product_Ex.php
28行目付近を以下に書き換え。
class SC_Product_Ex extends SC_Product {
function lists(&$objQuery) {
$col = <<< __EOS__
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
,deliv_date_id
,status
,del_flg
,update_date
,sub_title1
,sub_image1
,sub_title2
,sub_image2
,sub_title3
,sub_image3
,sub_title4
,sub_image4
,sub_title5
,sub_image5
__EOS__;
$where = 'dtb_products_class.del_flg = 0';
$res = $objQuery->select($col, $this->alldtlSQL($where));
return $res;
}
}
/data/Smarty/templates/default/products/list.tpl
205行目付近に以下を追加。
<!--{* サブ画像 *}-->
<!--{section name=cnt loop=$smarty.const.PRODUCTSUB_MAX}-->
<!--{assign var=key1 value="sub_title`$smarty.section.cnt.iteration`"}-->
<!--{assign var=key2 value="sub_image`$smarty.section.cnt.iteration`"}-->
<!--{if $arrProduct.$key2 != ''}-->
<img src="<!--{$smarty.const.ROOT_URLPATH}-->resize_image.php?image=<!--{$arrProduct.$key2|h|nl2br}-->&width=80&height=80" alt="<!--{$arrProduct.$key1|h}-->" />
<!--{/if}-->
<!--{/section}-->
以上です。
今回の題名に【Ver.2.11.5】をつけたのは、この技術が2.11.1と2.11.2では使えないらしいからです。
ひとまず、最新版である、2.11.5には使えるという事で。
