-1
我需要在註冊後更改客戶狀態。因此,當用戶嘗試在管理員批准後在我的站點中登錄時,他可以訪問帳戶,並且我想使用觸發器並更改該客戶的狀態,並更新給我的另一個SAP服務器數據庫所以在這裏,我需要知道什麼事件將被觸發在客戶狀態改變狀態..?請任何一個回答我的問題..如何使用magento中的觸發器(觀察者)進行用戶註冊
我需要在註冊後更改客戶狀態。因此,當用戶嘗試在管理員批准後在我的站點中登錄時,他可以訪問帳戶,並且我想使用觸發器並更改該客戶的狀態,並更新給我的另一個SAP服務器數據庫所以在這裏,我需要知道什麼事件將被觸發在客戶狀態改變狀態..?請任何一個回答我的問題..如何使用magento中的觸發器(觀察者)進行用戶註冊
這裏使用Netzarbeiter_CustomerActivation代碼
******碼************
公共函數c ustomerSaveAfter($ observer) {/ var @var Mage_Customer_Model_Customer $ customer */ $ customer = $ observer-> getEvent() - > getCustomer();
$helper = Mage::helper('customeractivation');
$storeId = $helper->getCustomerStoreId($customer);
if (! $helper->isModuleActive($storeId)) {
return;
}
$groupId = $customer->getGroupId();
$defaultStatus = $helper->getDefaultActivationStatus($groupId, $storeId);
try {
if (Mage::app()->getStore()->isAdmin()) {
if (!$customer->getOrigData('customer_activated') && $customer->getCustomerActivated()) {
// Send customer email only if it isn't a new account and it isn't activated by default
if (!($customer->getCustomerActivationNewAccount() && $defaultStatus)) {
$helper->sendCustomerNotificationEmail($customer);
*** Added Code Here **********
獲取用戶信息和管理員批准後,客戶的詳細信息將通過您的API被髮送到另一臺服務器
$CustomerID=$customer->getId();
$FirstName=$customer->getFirstname();
$MiddleName=$customer->getMiddlename();
$LastName=$customer->getLastname();
$Gender=$customer->getGender();
$EmailID=$customer->getEmail();
$WebSite=$customer->getWebsiteId();
$GroupID=$customer->getGroupId();
$DOB=$customer->getDob();
$TaxVat=$customer->getTaxvat();
$date= date("Ymd", strtotime($DOB));
$url = "http://server/WebSAPApi/Service1.asmx/CreateCustomer?CustomerID=$CustomerID&FirstName=$FirstName&MiddleName=$MiddleName&LastName=$LastName&Gender=$Gender&EmailID=$EmailID&WebSite=$WebSite&GroupID=$GroupID&DOB=$date&TaxVat=$TaxVat";
function httpGet($url)
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$msg = httpGet($url);
Mage::log($url.$msg, null, 'mylog.log', true);**
******所添加的代碼*******結束***
}
}
} else {
if ($customer->getCustomerActivationNewAccount()) {
// Only notify the admin if the default is deactivated or the "always notify" flag is configured
$alwaysNotify = Mage::getStoreConfig(self::XML_PATH_ALWAYS_NOTIFY_ADMIN, $storeId,$d);
if (!$defaultStatus || $alwaysNotify) {
$helper->sendAdminNotificationEmail($customer);
}
}
$customer->setCustomerActivationNewAccount(false);
}
} catch (Exception $e) {
Mage::throwException($e->getMessage());
}
}