今天简单的实现了一下ecshop商品导出到第三方的购买链接功能。
大致思路是给商品添加一个buy_link的text字段,存为json结构,然后通过json解析输出到商品购买页面
1.添加字段
增加购买链接字段,执行sql语句:
1 |
ALTER TABLE `ecs_goods` ADD `buy_link` TEXT NULL AFTER `goods_thumb` ; |
2.增加商品发布表单项
随意增加
2 |
<td class = "label" >购买链接</td> |
3 |
<td><textarea name= "buy_link" cols= "40" rows= "3" >{ $goods .buy_link}</textarea></br> |
4 |
使用了简单json结构,请严格按照格式填写(如:{ 'taobao' : 'http://' , '360buy' : 'http://' },</br>分别代表淘宝店和京东店内的购买连接) |
到/admin/templates/goods_info.htm,我增加在第258行下面(即,第三个table最后注意不要破坏table结构)
后台商品编辑页面多出了一个项目
3.增加读取数据
因为涉及到数据更新,应该先给表单填写初始值。在/admin/goods.php 446行下增加
1 |
$smarty ->assign( 'buy_link' , $goods [ 'buy_link' ]); |
4.增加发布商品存库
编辑/admin/goods.php页面821开始。取得表单传值buy_link,并在insert语句中增加中字段buy_link。可以直接修改为
1 |
$goods_thumb = ( empty ( $goods_thumb ) && isset( $_POST [ 'auto_thumb' ]))? $goods_img : $goods_thumb ; |
2 |
$buy_link = empty ( $_POST [ 'buy_link' ]) ? '' : trim( $_POST [ 'buy_link' ]); |
9 |
$sql = "INSERT INTO " . $ecs ->table( 'goods' ) . " (goods_name, goods_name_style, goods_sn, " . |
10 |
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " . |
11 |
"promote_start_date, promote_end_date, goods_img, goods_thumb, buy_link, original_img, keywords, goods_brief, " . |
12 |
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " . |
13 |
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id)" . |
14 |
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " . |
15 |
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', " . |
16 |
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$buy_link', '$original_img', " . |
17 |
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number'," . |
18 |
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, " . |
19 |
" '$_POST[goods_desc]', '" . gmtime() . "', '" . gmtime() . "', '$goods_type', '$rank_integral', '$suppliers_id')" ; |
23 |
$sql = "INSERT INTO " . $ecs ->table( 'goods' ) . " (goods_name, goods_name_style, goods_sn, " . |
24 |
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " . |
25 |
"promote_start_date, promote_end_date, goods_img, goods_thumb, buy_link, original_img, keywords, goods_brief, " . |
26 |
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " . |
27 |
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" . |
28 |
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " . |
29 |
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', " . |
30 |
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$buy_link', '$original_img', " . |
31 |
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number'," . |
32 |
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, " . |
33 |
" '$_POST[goods_desc]', '" . gmtime() . "', '" . gmtime() . "', '$goods_type', '$code', '$rank_integral')" ; |
,这样 增加商品时就能指定buy_link了
5.增加修改商品存库
在/admin/goods.php 901 行上的sql拼接上增加
1 |
"buy_link = '$buy_link', " . |
则变为
1 |
$sql .= "buy_link = '$buy_link', " . |
2 |
"keywords = '$_POST[keywords]', " . |
3 |
"goods_brief = '$_POST[goods_brief]', " . |
4 |
"seller_note = '$_POST[seller_note]', " . |
5 |
"goods_weight = '$goods_weight'," . |
6 |
"goods_number = '$goods_number', " . |
7 |
"warn_number = '$warn_number', " . |
8 |
"integral = '$_POST[integral]', " . |
9 |
"give_integral = '$give_integral', " . |
10 |
"rank_integral = '$rank_integral', " . |
11 |
"is_best = '$is_best', " . |
12 |
"is_new = '$is_new', " . |
13 |
"is_hot = '$is_hot', " . |
14 |
"is_on_sale = '$is_on_sale', " . |
15 |
"is_alone_sale = '$is_alone_sale', " . |
16 |
"is_shipping = '$is_shipping', " . |
17 |
"goods_desc = '$_POST[goods_desc]', " . |
18 |
"last_update = '" . gmtime() . "', " . |
19 |
"goods_type = '$goods_type' " . |
20 |
"WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1" ; |
由此,数据入库基本完成,现在做模版赋值。
6.模版赋值
goods_info函数已经读取出来所有数据,因此直接修改/goods.php( 注:是根目录下的),在197行下增加
3 |
//不是json数据则不予赋值,防止编辑格式错误致使前台js解析出错 |
5 |
if ( is_null (json_decode( $goods [ 'buy_link' ]))){ |
7 |
$smarty ->assign( 'buy_link' , $goods [ 'buy_link' ]); |
7.模版读取
修改商品详情模版,如/themes/default/goods.dwt。397行下增加
2 |
<!-- {if $buy_link != ""} --> |
3 |
< script type = "text/javascript" language = "javascript" > |
8 |
Jbuylink = eval("{$buy_link}"); |
9 |
for(i=0;i< Jbuylink.length ;i++){ |
10 |
text +='<a href = "'+Jbuylink[i].url+'" target = "_blank" >'+Jbuylink[i].text+'</ a > '; |
12 |
document.write("< br />"+text); |
ok,功能完成。
下面简单测试下:编辑任意商品buy_link属性为[{text:'淘宝购买',url:'http://taobao.com'},{text:'京东购买',url:'http://360buy.com?p=89899'}] 保存,查看页面,如图:
商品导出连接
由此,已经能够读取到导出链接了
第4步中的内容改为
2 |
< td class = "label" >购买链接</ td > |
3 |
< td >< textarea name = "buy_link" cols = "40" rows = "3" >{$goods.buy_link}</ textarea ></ br > |
4 |
请严格按照格式填写(如:[{text:'淘宝购买',url:'http://taobao.com'},{text:'京东购买',url:'http://360bu.com'}] </ br >分别代表淘宝店和京东店内的购买连接) |
- Android跳转淘宝、京东APP商品详情页
import Android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; imp ...
- 方便代理下单的EcStore收货地址一键分析插件,同时支持淘宝/京东/一号店
使用EcStore开展分销的网站,代理需要经常代客下单,每个客户收货地址都不同,要选择和填写多个内容才能完成地址输入:省.市.区.详细地址.收货人姓名.手机电话等,非常麻烦,也容易输入错误.安装EcS ...
- iOS开发 仿淘宝,京东商品详情3D动画
- (void)show { [[UIApplication sharedApplication].windows[0] addSubview:self.projectView]; CGRect fr ...
- AOP编程 - 淘宝京东网络处理
现象描述 当我们打开京东 app 进入首页,如果当前是没有网络的状态,里面的按钮点击是没有反应的.只有当我们打开网络的情况下,点击按钮才能跳转页面,按照我们一般人写代码的逻辑应该是这个样子: /** ...
- 开源第三方登录组件OAuthLogin2.0 支持QQ,阿里巴巴,淘宝,京东,蘑菇街,有赞等平台
Nuget地址:https://www.nuget.org/packages/OAuthLogin2.0/ 项目结构说明: AuthorizationProviders文件夹下主要存放内置的授权平台. ...
- 仿淘宝,京东红包雨(基于Phaser框架)
本红包雨项目是基于HTML5的游戏框架Phaser写的,最终形成的是一个canvas,所以性能很好,但是必须要说的是这个框架比较大,压缩后也有700K左右,所以请慎用. 代码地址: https://g ...
- vue mint-ui 实现省市区街道4级联动(仿淘宝京东收货地址4级联动)
demo及源码地址 https://github.com/artiely/citypicker 先去下载一个“省份.城市.区县.乡镇” 四级联动数据,然后 引入 import { Picker } f ...
- 解决safari里面淘宝京东页面无法打开以及打开后乱码的问题!
sqlite3 ~/Library/Keychains/*/ocspcache.sqlite3 'DELETE FROM responses WHERE responderURI LIKE " ...
- js原生淘宝京东宝贝放大镜效果
js实现商城放大镜效果 效果: 鼠标放上去会有半透明遮罩.右边会有大图片局部图. 鼠标移动时右边的大图片也会局部移动. 技术点: Event Event 是一个事件对象,当一个事件发生后,和当前事件发 ...
随机推荐
- MetInfo标签函数及参数
参数标签直接在页面中调用标签代码即可: 函数标签需要在页面PHP嵌入代码中通过参数定义转换方可使用,如$metlang=methtml_lang('-'),点击函数标签代码可查看函数标签详细使用方法: ...
- C#线程系列讲座(1):BeginInvoke和EndInvoke方法
一.C#线程概述 在操作系统中一个进程至少要包含一个线程,然后,在某些时候需要在同一个进程中同时执行多项任务,或是为了提供程序的性能,将要执行的任务分解成多个子任务执行.这就需要在同一个进程中开启多个 ...
- hibernate主键生成机制与save返回
主键生成机制为assigned时,save之后通过get得不到id(主键),使用identity可以. hibernate主键生成机制1) assigned主键由外部程序负责生成,无需Hibernat ...
- IntelliJ IDEA Community Edition 14.1.4下 javafx scenebuilder的使用
官网对应的配置文档:https://www.jetbrains.com/idea/help/preparing-for-javafx-application-development.html Java ...
- 从零开始攻略PHP(6)——代码重用与函数编写的一些注意事项
一个新的项目是这样创建的:它将已有的可重新利用的组件进行组合,并将新的开发难度降低到最小. 代码重用的好处:降低成本.提升可靠性和一致性. 1.使用require()和include()函数 使用一条 ...
- 学习OpenCV——hand tracking手势跟踪
这几日,岛上风云突变,我这个倒霉孩子终究木有躲过感冒的魔掌,中枪鸟~~~ 这几天只写了个简单的手势跟踪的代码. 原理是:背景差分+肤色检测. 背景差分:取前30帧图像取平均值,计算前30帧之差的和,再 ...
- SC-控制Windows服务的命令
Windows自带一个控制服务的命令-SC,下面用Terminal Service做个简单例子: 查询Terminal Service的配置 C:\Users\jackie.chen>sc qc ...
- PostgreSQL 三节点集群故障模拟及恢复
PostgreSQL 三节点集群故障模拟及恢复 (postgreSQL9.5.1) 正常状态: 10.2.208.10:node1:master 10.2.208.11:node2:standby1同 ...
- AngularJs Test demo &front end MVVM implementation conjecture and argue.
<!DOCTYPE html> <html> <head> <title></title> <meta charset="u ...
- Ubuntu 16.04 LTS Final Beta about JAVA
我们知道Ubuntu里可能会事先安装了openjdk.但是我习惯于Oracle jdk. ## < 卸载 openjdk > successfully: ### Terminal comm ...