# 在ec-cube中調用商品番號

- URL: https://justfly.idv.tw/%e5%9c%a8ec-cube%e4%b8%ad%e8%aa%bf%e7%94%a8%e5%95%86%e5%93%81%e7%95%aa%e8%99%9f/
- 日期: 2008-11-05
- 分類: WEB&amp;RIA
- 標籤: ec-cube, MySQL, php

再公司的網站中這是第二次調用了(上次用在商品list)

不過上次不曉得在忙啥就忘了筆記一下

結果這次要再用就又要從頭找過

所以這次還是做完就記一下吧!!

這次是要在各商品deital的オススメ商品也要出現商品番號

於是先改了\data\class\pages\productsLC_Page_Products_Detail.php

把product_code_min, product_code_max兩個參數也從data裡調出來:

```
/* 登録済みオススメ商品の読み込み */
    function lfPreGetRecommendProducts($product_id) {
        $arrRecommend = array();
        $objQuery = new SC_Query();
        $objQuery->setorder("rank DESC");
        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
        $max = count($arrRet);
        $no = 0;
        $from = "vw_products_allclass AS T1 "
                . " JOIN ("
                . " SELECT max(T2.rank) AS product_rank, "
                . "        T2.product_id"
                . "   FROM dtb_product_categories T2  "
                . " GROUP BY product_id) AS T3 USING (product_id)";
        $objQuery->setorder("product_rank DESC");
        for($i = 0; $i < $max; $i++) {
            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1";
            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, product_rank, product_code_min, product_code_max", $from, $where, array($arrRet[$i]['recommend_product_id']));

            if(count($arrProductInfo) > 0) {
                $arrRecommend[$no] = $arrProductInfo[0];
                $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
                $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
                $no++;
            }
        }
        return $arrRecommend;
    }
```

然後改\html\user_data\packages\mystyledetail.tpl

在想加的地方放上去ok了(當然還要修一下css囉)

```
製品型番：
        
          〜
```
