ecshop如何给商品自定义字段

最近想用ecshop做一个淘宝客商城系统,就需要对ecshop原有的基础上做一些二次开发那么就简单的去了解了一下ecshop里面的一些知识,正好要处理ecshop给商品自定义字段属性问题,这个要如何做呢?在下面的内容中小编将详细的给大家介绍一下,这里我会补充一下网上的一些错误,我发现网上有的地方有错误这里将给大家更正。

具体操作步骤:

例如这里我要给商品添加一个URL字段
1.登陆ecshop后台,数据库管理 》SQL查询,输入下面SQL语句,
alter table ecs_goods add column other_url varchar(64);//表示的意思是给ecs_goods中添加一个字段other_url;

2.在打开你的ecshop程序,在admin\templates\文件夹中找到goods_info.htm文件,打开编辑里面的代码。
<tr>
<td>商品的推广地址</td>
<td><input type=”text” name=”other_url” value=”{$goods.other_url}” size=”40″/>
</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]‘)”;
上面是增加新字段的操作,下面我们还要做的就是修过字段的操作修改:
$sql = “UPDATE ” . $ecs->table(‘goods’) . ” SET ” . 在这一句的下面添加”other_col =’$_POST[other_col]‘,” . ;这样就可以正常的进行修改操作了。

4.那么下面剩下的就是我们在模板页面调用这个标签了,比如我这里要修改的是商品详细页面了,我首先进入的是主题栏目下面
记住所有的ecshop模板文件都在themes下面。
我们只要在对应的位置调用:调用方法:{$goods.other_url}  ;

到这里我们添加自定义字段就算给大家讲解完了,如果大家有什么不明白的欢迎联系我们一起交流。

本文固定链接: http://www.idc-blog.com/?p=441 | 网络菜鸟学习园地

该日志由 admin 于2013年07月03日发表在 ecshop二次开发 分类下,
原创文章转载请注明: ecshop如何给商品自定义字段 | 网络菜鸟学习园地
关键字: ,

报歉!评论已关闭.