ECshop在導入淘寶數據包的時候出現數據亂碼。php
測試版本 ecshop2.73數組
利用淘寶助手導出一個數據包(.csv),不要一次所有商品導出,最好是將數據包控制在1M左右,由於ecshop對上傳文件有限制。編輯器
一、用編輯器打開文件goods_batch.php,文件在admin文件夾下,找到測試
$data=file($_FILES['file']['tmp_name']);編碼
並將此行註釋掉。在下邊加上 spa
$data0=mb_convert_encoding(file_get_contents($_FILES['file']['tmp_name']),"utf-8","UTF-16LE");code
注:utf-8是ecshop的版本編碼,若是是gbk則這裏是gbkblog
二、繼續添加代碼圖片
$data=str_replace("\"\"","\"",$data0);utf-8
$data=explode('歐韓站外貿倉,$data);
歐韓站外貿倉是店鋪的名字,將這個換成你店鋪的名字便可。
三、這裏開始要特別注意,由於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)而後修改錯誤的數組下標。
四、到了這裏數據的提取基本上完成了,下面就要對提取的數據進行處理並賦值給數組。其實也只是圖片的數據須要處理一下,具體以下:
$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;
五、最後要處理的數據就是圖片的路徑。找到if (!empty($field_arr['original_img']))的位置,有這裏開始註釋,一直到//修改商品圖這裏,而後再註釋//添加商品相冊圖下面的if代碼。