zencart网站改版或是重做顾客材料迁移专用工具

2021-03-30 21:29| 发布者: | 查看: |

新闻报道引言:zencart网站改版或是重做顾客材料迁移专用工具 好长时间没给大伙儿共享点有效的物品了,今日抽时间写了一个zencart顾客材料迁移合拼专用工具,觉得還是有点儿用的,就共享给大伙儿
关键的主要用途便是就一个zencart网站的顾客所有转移到另外一个网站
?php
// +----------------------------------------------------------------------
// | Project:Zencart转移升級(顾客材料导进导出来)
// +----------------------------------------------------------------------
// | Explanation:2016-11-1
// +----------------------------------------------------------------------
// | Version: V1.8
// +----------------------------------------------------------------------
header('Content-Type:text/html;charset=UTF-8');
require('');
function ez_get_customers_books($customers_id,$customers_default_address_id){
  global $db;
  $books_data=array();
  $books=$db- Execute("SELECT * FROM ".TABLE_ADDRESS_BOOK." WHERE customers_id=".$customers_id);
  while(!$books- EOF){
    $books- fields['primary'] = ($books- fields['address_book_id']==$customers_default_address_id) ? 1 : 0;
    $books_data[]=$books- fields;
    $books- MoveNext();
  }
  return $books_data;
}
($customers_id){
  global $db;
  $=$db- Execute("SELECT * FROM ".TABLE_CUSTOMERS_INFO." _id=".$customers_id);
  unset($- fields['_id']);
  return $- fields;
}
$customers_data=array();
//导出来
if($_GET['toolaction']=='export'){
  $customers = $db- Execute("SELECT * FROM ".TABLE_CUSTOMERS);
  while(!$customers- EOF){
    $customers- fields['books']=ez_get_customers_books($customers- fields['customers_id'],$customers- fields['customers_default_address_id']);
    $customers- fields['']=($customers- fields['customers_id']);
    $customers_data[$customers- fields['customers_email_address']]=$customers- fields;
    $customers- MoveNext();
  }
  file_put_contents(DIR_FS_SQL_CACHE.'/customers_data.log', json_encode($customers_data));
  echo '导出来取得成功';
  exit;
}
//导进
if($_GET['toolaction']=='import'){
  if(!file_exists(DIR_FS_SQL_CACHE.'/customers_data.log')) {echo '顾客材料文档不会有';die;}
  $customers_data_json=file_get_contents(DIR_FS_SQL_CACHE.'/customers_data.log');
  $customers_data=json_decode($customers_data_json,true);
  foreach($customers_data as $email_address = $email_data){
    $check_email_query = "select count(*) as total
                            from " . TABLE_CUSTOMERS . "
                            where customers_email_address = '" . $email_address . "'";
    $check_email = $db- Execute($check_email_query);
    if ($check_email- fields['total'] 0) continue;  //电子邮箱已存有跳出来
    $book_data=$email_data['books'];
    $=$email_data[''];
    unset($email_data['books'],$email_data['customers_id'],$email_data['']);
    //插进顾客表
    zen_db_perform(TABLE_CUSTOMERS, $email_data);
    $customers_id = $db- Insert_ID();
    //插进顾客信息内容表
    $['_id']=$customers_id;
    zen_db_perform(TABLE_CUSTOMERS_INFO, $);
    //插进详细地址表
    foreach($book_data as $book){
      $book['customers_id']=$customers_id;
      unset($book['address_book_id']);
      $primary= ($book['primary']==1) ? 1 : 0;
      unset($book['primary'],$book['address_book_id']);
      zen_db_perform(TABLE_ADDRESS_BOOK, $book);
      $books_id = $db- Insert_ID();
      //升级顾客表默认设置详细地址
      if($primary==1)  $db- Execute("UPDATE ".TABLE_CUSTOMERS." SET customers_default_address_id=".$books_id." WHERE customers_id=".$customers_id);
    }
  }
  echo '导进取得成功';
  exit;
}
?
a href="?toolaction=export" 导出来 /a
a href="?toolaction=import" 导进 /a
应用方式非常简单,仅用将文档提交到网站网站根目录,随后访问器运作customers_populate.php,导出来后将cache/customers_data.log迁移到另外一个站的cache下,随后实行导进
<
>

 
QQ在线咨询
售前咨询热线
18720358503
售后服务热线
18720358503
返回顶部