ecshop在添加新商品时加入任意字段并模板中调用

 

ecshop在添加新商品时加入任意字段并模板中调用

1.ecshop数据库新增一个字段

可以用mysql语句,也可以用phpmyadmin或其它数据库管理工具增加ecshop字段

2.修改admin/good.php

查找 $shop_price = !empty($_POST[‘shop_price’]) ? $_POST[‘shop_price’] : 0;

在下面添加

$goods_profit = !empty($_POST[‘goods_profit’]) ? $_POST[‘goods_profit’] : 0;

查找 if ($is_insert)

在4处地方加入SQL的插入。

我插入后的语句

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_profit, 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)” .
“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_profit’, ‘$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’)”;
}
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_profit, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, 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_profit’, ‘$goods_number’,”.
” ‘$warn_number’, ‘$_POST[integral]’, ‘$give_integral’, ‘$is_best’, ‘$is_new’, ‘$is_hot’, 0, ‘$is_on_sale’, ‘$is_alone_sale’, $is_shipping, “.
” ‘$_POST[goods_desc]’, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$code’, ‘$rank_integral’)”;
}
}

基本上就是在对应的goods_weight后面加入goods_profit 总共有4处

查找 “goods_weight = ‘$goods_weight’,” .

在下面加入

“goods_profit = ‘$goods_profit’,”.

在后台添加新商品的地方加入商品利润

找到 admintemplatesgoods_info.htm

在你想加入的地方添加

<tr>
<td class=”label”>商品利润:</td>
<td><input type=”text” name=”goods_profit” value=”{$goods.goods_profit}” size=”20″ />
</td>
</tr>

在模板中用{$goods.goods_profit} 来调用,我们一般再good.dwt里面调用

后台商品列表页显示这个字段请看我下一篇文章,并可以ajax修改

相关推荐

magento 2.3 nginx 安装

在网上看了许多中文的magento2的安装教程,大多数都没有完整的安装步骤,本教程将教会你怎么使用和安装magento2.3 …

Magento忘记密码怎么办

如果你忘记 Magento 用户名和(或)密码无法登陆后台,并且forgot your password链接无法给你发送找回密码邮件,这 …

magento backend dashboard can’t log in – session error

可能很多朋友有同样的经历,magento在服务器中配置域名是可以正常的访问了,但是在本地配置后却无法登录后台,账号密码登录的时候发现出现空白,无法跳转到后台,本文章向大家介绍两种解决本地magento后台无法登录的方法,需要的朋友可以参考下

暂无评论

发表评论

微信扫一扫,分享到朋友圈

ecshop在添加新商品时加入任意字段并模板中调用