ECSHOP 商品字段增加新字段的方法

2021-09-07 08:30:47 字數 2036 閱讀 3552

結合ecshop後台「商品編輯」、「商品錄入」來談談如何給ecshop商品增加乙個新字段,假設我們將這個新字段命名為 new_add

1、首先要修改資料表結構,給表 ecs_goods 增加新字段:new_add,

進入ecshop後台 》資料庫管理 》sql查詢,輸入下面sql語句,提交。注意如果你的資料表字首不是ecs_ 請自行修改之

alter table ecs_goods add column new_add varchar(64);

2、在ecshop後台的admin\templates\goods_info.htm中增加以下**.

自定義字段

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,new_add)" .

"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[new_add]')";

//下面這個為更新,在:

$sql = "update " . $ecs->table('goods') . " set " .

"goods_name = '$_post[goods_name]', " .

"goods_name_style = '$goods_name_style', " .

下面加" new_add = '$_post[new_add]', " .

這樣我們就完成了在ecshop後台錄入和修改新字段的功能了。

下面再來說一下前台呼叫的方法:

呼叫也很簡單,直接在模板檔案或者 lbi檔案裡 這麼呼叫即可

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

在ecshop二次開發工作之如何給商品增加乙個新字段,來錄入一些新的內容。下面我們結合ecshop後台 商品編輯 商品錄入 來談談如何給ecshop商品增加乙個新字段,假設我們將這個新字段命名為 other col 1 首先要修改資料表結構,給表 ecs goods 增加新字段 other col,...

更新欄位的sql

update pro traininfo t set t.totalmoney select a.price t.totaltime from gen makepriceinfo a where a.studentcode t.studentcode and a.examcode t.examcod...

ES索引新增新字段

當es索引因需求需要新增欄位時,有三種方案 通過刪除舊索引,新建新索引來解決,但是這種方案需要全量跑資料,且平台會出現短暫不可用,不建議使用 新建立乙個臨時索引,然後把舊索引資料匯入後,再把新索引別名命名為舊索引,但這種方式,索引別名讓雖然不影響使用,但是很難受 直接通過命令來實現 修改es索引,推...