Blog

【ECCUBE2.13】商品詳細の関連商品(その他オススメ商品)にステータスアイコンを表示

2016/05/27

ECCUBE2.13 ECCUBE

以前にカスタムをしましたが、忘れないように備忘録として残します。

参考サイト
[EC-CUBE 2.12.2] 商品詳細のその他オススメ商品にステータスアイコンを表示させたい

data/class/pages/products/LC_Page_Products_Detail.php の 関連商品情報表示 の下あたりに、関連商品ステータス取得コードを追加

参考サイトですと最後の商品だけアイコンが表示されてしまうので、
修正をしています。

//関連商品情報表示
$this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);

//関連商品の商品ステータスを取得
if(count($this->arrRecommend) > 0){
    $this->recommendProductStatus = array();
    foreach($this->arrRecommend as $val){
        $this->recommendProductStatus += $objProduct->getProductStatus($val['product_id']);
    }
}

data/Smarty/templates/default/products/detail.tpl の関連商品部分のコードを以下のような感じで修正

<!--▼関連商品-->
<!--{if $arrRecommend}-->
    <div id="whobought_area">
        <h2><img src="<!--{$TPL_URLPATH}-->img/title/tit_product_recommend.jpg" alt="その他のオススメ商品" /></h2>
        <!--{foreach from=$arrRecommend item=arrItem name="arrRecommend"}-->
            <div class="product_item">
                <div class="productImage">
                    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}-->">
                        <img src="<!--{$smarty.const.ROOT_URLPATH}-->resize_image.php?image=<!--{$arrItem.main_list_image|sfNoImageMainList|h}-->&amp;width=65&amp;height=65" alt="<!--{$arrItem.name|h}-->" /></a>
                </div>
                <!--{assign var=price02_min value=`$arrItem.price02_min_inctax`}-->
                <!--{assign var=price02_max value=`$arrItem.price02_max_inctax`}-->
                <div class="productContents">
                    <!--▼商品ステータス追加-->
                    <!--{assign var=ps value=$recommendProductStatus[$arrItem.product_id]}-->
                    <!--{if count($ps) > 0}-->
                    <ul class="status_icon clearfix">
                        <!--{foreach from=$ps item=status}-->
                            <li>
                                <img src="<!--{$TPL_URLPATH}--><!--{$arrSTATUS_IMAGE[$status]}-->" width="60" height="17" alt="<!--{$arrSTATUS[$status]}-->" id="icon<!--{$status}-->" />
                            </li>
                        <!--{/foreach}-->
                    </ul>
                    <!--{/if}-->
                    <!--▲商品ステータス-->

                    <h3><a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}-->"><!--{$arrItem.name|h}--></a></h3>
                    <p class="sale_price"><!--{$smarty.const.SALE_PRICE_TITLE}-->(税込):<span class="price">
                        <!--{if $price02_min == $price02_max}-->
                            <!--{$price02_min|number_format}-->
                        <!--{else}-->
                            <!--{$price02_min|number_format}-->~<!--{$price02_max|number_format}-->
                        <!--{/if}-->円</span></p>
                    <p class="mini"><!--{$arrItem.comment|h|nl2br}--></p>
                </div>
            </div><!--{* /.item *}-->
            <!--{if $smarty.foreach.arrRecommend.iteration % 2 === 0}-->
                <div class="clear"></div>
            <!--{/if}-->
        <!--{/foreach}-->
    </div>
<!--{/if}-->
<!--▲関連商品-->

実際には、Exファイルをカスタムしています。

ステータスアイコンの位置は任意で移動してください。



カテゴリー

月間アーカイブ

MORE

ミュージシャンズ・プラザ

神社仏閣ホームーページ制作

ホームページ制作問合せ