ecshop文章和商品转移到wordpress的办法

做网店,以前流行 ecshop 之类的国产 PHP 系统,但后来很多开源项目要么都是伪开源处处收费,要么就是很久都不再维护更新,要么就是漏洞很多遭受攻击。总之,国产的 CMS 系统真的是用怕了!

用过很多国产网店系统、CMS 系统,到头来发现还是 Wordpress 好用。为什么呢?首先,Wordpress 是真开源,不用担心商业使用被起诉的问题。另外,Wordpress 经常在更新,有什么漏洞会及时补上,避免了安全问题。最主要的是,Wordpress 非常灵活,插件非常多,用它来做企业网站、商城(Woocommerce 插件)、小程序后台等都适合,如果是搞跨境电商网站那就更适合不过了。

我有个网店以前是 ecshop 做的,后来这套系统很久不更新不说,安全、架构等等都是问题,即使收费版本也不好用,最终不得不放弃,改用 Wordpress + Woocommerce,发现这套组合是真香啊。

下面介绍我的转移数据的办法。ecshop 文章和商品转移到 wordpress 的 SQL:

第一步是复制商品数据:

INSERT INTO wp_posts(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status,ping_status,  post_name,to_ping, pinged,post_modified, post_modified_gmt, post_content_filtered, guid,  post_type) 

SELECT 
goods_id as ID,
1 as post_author,
'2023-01-07 21:44:57' as post_date,
'2023-01-07 21:44:57' as post_date_gmt,
goods_desc as post_content,
goods_name as post_title,
''as  post_excerpt,'private'as post_status,'open'as comment_status ,'open' as ping_status,

-- 商品 id 用来做 post_name 是为了换系统后 URL 不丢失,后面会提到
goods_id as post_name,
''as to_ping,'' as pinged,
'2023-01-01 14:37:37' as post_modified,
'2023-01-01 14:37:37' as post_modified_gmt,
'' as post_content_filtered,
CONCAT('http:// 你的域名 /article-',goods_id, '.html') as guid,
'product' as post_type
 from ecs_goods

第二步是复制文章数据:

INSERT INTO wp_posts(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status,ping_status,  post_name,to_ping, pinged,post_modified, post_modified_gmt, post_content_filtered, guid,  post_type) 
select 
ID,
1 as post_author,
'2023-01-01 14:37:37' as post_date,
'2023-01-01 14:37:37' as post_date_gmt,
content as post_content,
title as post_title,
IFNULL(description, '') as  post_excerpt,'private'as post_status,'open'as comment_status ,'open' as ping_status,
title as post_name,
''as to_ping,'' as pinged,
'2023-01-01 14:37:37' as post_modified,
'2023-01-01 14:37:37' as post_modified_gmt,
'' as post_content_filtered,
CONCAT('http:// 您的域名 /article-',ID, '.html') as guid,
'post' as post_type
from ecs_article;

INSERT INTO wp_term_relationships(object_id, term_taxonomy_id, term_order) 
SELECT Id as object_id,
187 as term_taxonomy_id,
0 as term_order
from ecs_article

第三步是配置伪静态

经过上面两步的操作,基本上已经把原网站的数据搬到了 Wordpress,放在了私密里面,自己编辑一下发布即可。为了保证网站换系统后 URL 不丢失,还需要配置伪静态。

在 Wordpress 的固定链接设置里,设置自定义结构为 /article-%post_id%.html

Nginx 的伪静态配置也需要修改。在 location 里面加一行:

rewrite ^/goods-([0-9]+).html$ /product/$1 permanent;

这样做的目的是:原来的商品链接 /goods-id.html 自动重定向到 /product/id

ecshop 文章和商品转移到 wordpress 的办法

做完这些,网站数据迁移就基本完成了。Wordpress 虽然刚入手的时候复杂一点,因为它太灵活,但就因为太灵活,所以用来做任何网站、小程序后台都适合。WP 用到了国外的在线字体原因导致后台打开很慢,但这些都有插件来解决。不得不说,用 Wordpress + Woocommerce 真的是比用国产的任何网店系统都省心!

正文完
 0
评论(没有评论)