ECshop导入淘宝数据包乱码问题解决方法

it2022-05-06  9

ECshop在导入淘宝数据包的时候出现数据乱码。

测试版本 ecshop2.73

利用淘宝助手导出一个数据包(.csv),不要一次全部商品导出,最好是将数据包控制在1M左右,因为ecshop对上传文件有限制。

 

1、用编辑器打开文件goods_batch.php,文件在admin文件夹下,找到

$data=file($_FILES['file']['tmp_name']);

并将此行注释掉。在下边加上 

$data0=mb_convert_encoding(file_get_contents($_FILES['file']['tmp_name']),"utf-8","UTF-16LE");

注:utf-8是ecshop的版本编码,如果是gbk则这里是gbk

 

2、继续添加代码

$data=str_replace("\"\"","\"",$data0);

$data=explode('欧韩站外贸仓,$data);

欧韩站外贸仓是店铺的名字,将这个换成你店铺的名字即可。

 

3、这里开始要特别注意,因为csv文件的开头有一部分说明,所以要针对首行特别处理。

if($k==0){ $goods_name_arr = explode('"',$line_list[98]); $goods_name = $goods_name_arr[1]; $shop_price = $line_list[105]; $goods_number = $line_list[107]; $imgsstr = $line_list[126]; $goods_desc =str_replace("\"","'",substr($line_list[118],1,strlen($line_list[118])-2)); }else{$goods_name_arr = explode('"',$line_list[10]); $goods_name = $goods_name_arr[1]; //$goods_name = trim($line_list[10],'"'); $shop_price = $line_list[17]; $goods_number = $line_list[19]; $imgsstr = $line_list[38]; $goods_desc = str_replace("\"","'",substr($line_list[30],1,strlen($line_list[30])-2)); }

这里的$line_list[]可能会因为店铺商品属性不一样导致数据提取错误,可以先print_r($line_list)然后修改错误的数组下标。

 

4、到了这里数据的提取基本上完成了,下面就要对提取的数据进行处理并赋值给数组。其实也只是图片的数据需要处理一下,具体如下:

$imgasd=str_replace("\"","",$imgsstr); $imgasd=explode(";",$imgasd); foreach($imgasd as $ks=>$vs){ if($ks!=count($imgasd)-1){ $nv=explode("|",$vs); $in=explode(":",$nv[0]); $imgs_u.=$in[0].".jpg;"; } } $arr['original_img'] = $imgs_u;

 

5、最后要处理的数据就是图片的路径。找到if (!empty($field_arr['original_img']))的位置,有这里开始注释,一直到//修改商品图这里,然后再注释//添加商品相册图下面的if代码。

 

转载于:https://www.cnblogs.com/wangblognet/p/3569822.html

相关资源:数据结构—成绩单生成器

最新回复(0)