ECSHOP二次開發之給商品增加新字段


ECSHOP二次開發工作之如何給商品增加一個新字段,來錄入一些新的內容。


下面我們結合ecshop后台“商品編輯”、“商品錄入”來談談如何給ecshop商品增加一個新字段,假設我們將這個新字段命名為 other_col
 


1、首先要修改數據表結構,給表 ecs_goods 增加新字段:other_col,


       進入ECSHOP后台 》數據庫管理 》SQL查詢,輸入下面SQL語句,提交。注意如果你的數據表前綴不是ecs_ 請自行修改之

     alter table ecs_goods add column other_col varchar(64);

 

 

2、在ecshop后台的admin\templates\goods_info.htm中增加以下代碼.

------------------------------------------------------------------------------------------------

    <tr>


            <td class="label">自定義字段</td>


            <td><input type="text" name="other_col" value="{$goods.other_col}" size="20"/>


            </td>


    </tr>

------------------------------------------------------------------------------------------------

 

 

3、在admin/goods.php的elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update')里面增加以下程序

 

------------------------------------------------------------------------------------------------

     $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .


                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .


                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .


                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .


                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id,other_col)" .


                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .


                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".


                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".


                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".


                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".


                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id','$_POST[other_col]')";



" other_col = '$_POST[other_col]', " .

------------------------------------------------------------------------------------------------

 

      這樣就完成了在ECSHOP后台錄入和修改新字段的功能了。

 

      下面再來說一下前台調用的方法:

      直接在模板文件或者  lbi文件里 這么調用即可 {$goods.other_col}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM