我有csv in which have lot of email is exit
,它想要assign those email to newsleter subscription list
。誰我會做....如何導入通訊用戶用戶csv在magento
而且check how skip for exiting customer because there are already list in newsleter
我有csv in which have lot of email is exit
,它想要assign those email to newsleter subscription list
。誰我會做....如何導入通訊用戶用戶csv在magento
而且check how skip for exiting customer because there are already list in newsleter
由於krupal帕特爾沒有爲後回答這樣足夠的聲譽,而不是他,我已經把答案。
按照此步驟
步驟1添加import.php file in Magento root directory
這個代碼應該是
<?php
$store_id = 1;
$csv_filepath = "subscribers.csv";
$csv_delimiter = ',';
$csv_enclosure = '"';
$magento_path = __DIR__;
require "{$magento_path}/app/Mage.php";
Mage::app()->setCurrentStore($store_id);
echo "<pre>";
$fp = fopen($csv_filepath, "r");
if (!$fp) die("{$csv_filepath} not found\n");
$count = 0;
while (($row = fgetcsv($fp, 0, $csv_delimiter, $csv_enclosure)) !== false){
if ($count != 0){
$email = trim($row[1]);
$type = trim($row[2]);
$fname = trim($row[3]);
$lname = trim($row[4]);
$status = trim($row[5]);
$website = trim($row[6]);
$store = trim($row[7]);
$store_view = trim($row[8]);
if (strlen($email) == 0) continue;
echo "$email";
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
if ($subscriber->getId()){
echo $email . " <b>already subscribed</b>\n";
continue;
}
Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($email);
$subscriber_status = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
if ($status == 1){
$subscriber_status->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
$subscriber_status->save();
}else if($status == 2){
$subscriber_status->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
$subscriber_status->save();
}else if($status == 3){
$subscriber_status->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
$subscriber_status->save();
}else if($status == 4){
$subscriber_status->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED);
$subscriber_status->save();
}
echo $email . " <b>ok</b>\n";
}
$count++;
}
echo "Import finished\n";
步驟2Add subscribers.csv
文件中Magento root directory
步驟3:Run import.php file
在根目錄下像(http://domainname.com/import.php
)
第4步:進入管理菜單Newsletter > Newsletter Subscribers and finally you subscriber user CSV file import
訪問鏈接代碼= http://krupalpatel92.blogspot.com/2014/09/magento-newsletter-subscriber-csv-file.html
振作起來krupal帕特爾
krupal patel,請接受這個答案。 – 2014-09-05 08:06:12
我已更新此代碼以導入具有狀態的用戶電子郵件。也更新CSV文件格式 – 2014-09-05 08:14:32
Goood .. krupal .... – 2014-09-05 08:15:15
難道不是工作 – 2014-09-05 05:59:54
添加import.php文件根目錄也csv文件和csv文件名是subscribers.csv和內部代碼是相同的檢查 – 2014-09-05 06:04:07
你有單店ya多店 – 2014-09-05 06:04:13