在magento中,我想在注册新帐户时为客户分配.edu电子邮件地址。
到目前为止,我已遵循本指南:http://www.fontis.com.au/blog/magento/automatically-set-magento-customer-group
我只想改变最后一点。如果他们的电子邮件地址以.edu结尾,我想将他们分配给第4组,而不是客户选择他们的风味
到目前为止,我有以下内容
<?php
class College_Customer_Model_Customer_Observer extends Mage_Core_Model_Abstract
{
/*
* observer for the customer saved event
*/
public function customer_save_before( $observer )
{
try {
$customer = $observer->getCustomer();
$email = $observer->getCustomerEmail();
if( (substr($email, strrpos($email, ".")+1) == "edu") )
$customer->setData( 'group_id', 4 );
else
$customer->setData( 'group_id', 1);
} catch ( Exception $e ) {
Mage::log( "customer_save_before observer failed: " . $e->getMessage() );
}
}
}
?>
我已经测试了
(substr($email, strrpos($email, ".")+1) == "edu")
我不认为这是问题所在。我想知道我是否将客户电子邮件称为错误。
感谢任何帮助
谢谢大家
低音
答案 0 :(得分:0)
您确定收到客户电子邮件吗?试试这个:
$customer = $observer->getEvent()->getCustomer();
$email = $customer->getEmail();