zoukankan      html  css  js  c++  java
  • ECSHOP 商品字段增加新字段的方法

    结合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 emplatesgoods_info.htm中增加以下代码.

    <tr>
    <td class="label">自定义字段</td>
    <td><input type="text" name="new_add" value="{$goods.new_add}" 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,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文件里 这么调用即可 {$goods.new_add}

  • 相关阅读:
    计科4班曾祥刚2016024290
    线程:子线程先循环十次,主线程在循环20次,再子线程循环十次,主线程循环20次,如此循环50次
    java经典程序(11-20)
    java经典程序(1-10)
    String,File和xml
    自写一个双向链表
    i love my girl
    javamail发邮件
    Java反射机制(创建Class对象的三种方式)
    java基础面试题
  • 原文地址:https://www.cnblogs.com/xiangsj/p/6250744.html
Copyright © 2011-2022 走看看