ecshop 在商品类表页添加类似于精品的自定义字段
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
在商品列表页添加自定义字段 1、首先要修改数据表结构,给表 ecs_goods 增加新字段:other_col, 进入ECSHOP后台 》数据库管理 》SQL查询,输入下面SQL语句,提交。注意如果你的数据表前缀不是ecs_ 请自行修改之 alter table ecs_goods add column other_col varchar(64); 2. 打开admin/goods.php 在/* 处理商品数据 */那里 $is_hot = isset($_POST['is_hot']) ? 1 : 0;(大约803行) $other_col = isset($_POST['other_col']) ? 1 : 0; 在 /* 入库 */添加 /* 入库 */ if ($is_insert) { if ($code == ”) { $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, other_col,” . “is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id)” . “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’,'$other_col’, ‘$is_on_sale’, ‘$is_alone_sale’, $is_shipping, “. ” ‘$_POST[goods_desc]‘, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$rank_integral’, ‘$suppliers_id’)”; } else { $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, other_col,is_real, ” . “is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)” . “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’,'$other_col’, 0, ‘$is_on_sale’, ‘$is_alone_sale’, $is_shipping, “. ” ‘$_POST[goods_desc]‘, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$code’, ‘$rank_integral’)”; } } 在 /* 如果有上传图片,需要更新数据库 */ $sql .= “keywords = ‘$_POST[keywords]‘, ” . “goods_brief = ‘$_POST[goods_brief]‘, ” . “seller_note = ‘$_POST[seller_note]‘, ” . “goods_weight = ‘$goods_weight’,” . “goods_number = ‘$goods_number’, ” . “warn_number = ‘$warn_number’, ” . “integral = ‘$_POST[integral]‘, ” . “give_integral = ‘$give_integral’, ” . “rank_integral = ‘$rank_integral’, ” . “is_best = ‘$is_best’, ” . “is_new = ‘$is_new’, ” . “other_col = ‘$other_col’, ” . “is_hot = ‘$is_hot’, ” . “is_on_sale = ‘$is_on_sale’, ” . “is_alone_sale = ‘$is_alone_sale’, ” . “is_shipping = ‘$is_shipping’, ” . “goods_desc = ‘$_POST[goods_desc]‘, ” . “last_update = ‘”. gmtime() .”‘, “. “goods_type = ‘$goods_type’ ” . “WHERE goods_id = ‘$_REQUEST[goods_id]‘ LIMIT 1″; 在 /* 取消新品 */后添加 /* 设为other_col */ elseif ($_POST['type'] == ‘other_col’) { /* 检查权限 */ admin_priv(‘goods_manage’); update_goods($goods_id, ‘other_col’, ’1′); } /* 取消other_col */ elseif ($_POST['type'] == ‘not_other_col’) { /* 检查权限 */ admin_priv(‘goods_manage’); update_goods($goods_id, ‘other_col’, ’0′); } 在 //– 修改新品推荐状态后面 /*—————————————————— */ //– 修改other_col推荐状态 /*—————————————————— */ elseif ($_REQUEST['act'] == ‘toggle_other_col’) { check_authz_json(‘goods_manage’); $goods_id = intval($_POST['id']); $other_col = intval($_POST['val']); if ($exc->edit(“other_col = ‘$other_col’, last_update=” .gmtime(), $goods_id)) { clear_cache_files(); make_json_result($other_col); } } 3.admin/templates/goods_info.htm 搜索is_new在{$lang.is_hot}后面添加 <input type=”checkbox” name=”other_col” value=”1″ {if $goods.other_col} checked=”checked”{/if} /> other_col 在大约204行{$lang.auto_thumb}后面添加 <tr> <td class=”label”>自定义字段</td> <td><input type=”text” name=”other_col” value=”{$goods.other_col}” size=”20″/> </td> </tr> 4.在admin/templates/goods_list.htm 在31行{$lang.handler}后 添加 <th><a href=”javascript:listTable.sort(‘other_col’); “>自定义</a>{$sort_other_col}</th> 在66行后添加 <td align=”center”><img src=”images/{if $goods.other_col}yes{else}no{/if}.gif” onclick=”listTable.toggle(this, ‘toggle_other_col’, {$goods.goods_id})” /></td> 这样就可以了,另外listTable.toggle()函数在admin下的js里的listtable.js里大家可以看下 |
最近更新
常用插件
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
ecshop热门问答
ecshop热门资料
ecshopidc
ecshopundefied
ecshop bug
ecshop密码
hantoomjs
ecshopIncorrect
ecshopnav
ecshop单张
ecshopINSTALLA
ecshop缩略图
ecshop康盛
ecshop这么
ecshop添加超值礼包
ecshop网站管理
ecshop设为首页
ecshop云中文
ecshop英文名字
ecshop缺损
ecshop单引号
ecshoptmp
ecshop瑞星
ecshop163
ecshop省略号
ecshop录入赠品
ecshop阶梯
ecshopT恤
ecshopfeedback
ecshopMORE
ecshop长沙php
ecshop跪拜