ECshop導入淘寶數據包亂碼問題解決方法


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代碼。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM