Php Magento需要向特定客户群发送自定义帐户确认电子邮件
我一直在翻阅文件,挠头。发送新帐户创建电子邮件的功能在哪里?一旦我找到它,我会用什么变量来表示特定的客户群 编辑2/18 根据下面的建议,我正在查看Customer.php文件并查看以下函数:Php Magento需要向特定客户群发送自定义帐户确认电子邮件,php,magento,Php,Magento,我一直在翻阅文件,挠头。发送新帐户创建电子邮件的功能在哪里?一旦我找到它,我会用什么变量来表示特定的客户群 编辑2/18 根据下面的建议,我正在查看Customer.php文件并查看以下函数: public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0') { $types = array( 'registered' =>
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
$types = array(
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
);
if (!isset($types[$type])) {
Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
}
if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
$this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
array('customer' => $this, 'back_url' => $backUrl), $storeId);
return $this;
}
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
//Caitlin Havener
//What Group do you belong to?
if($session->isLoggedIn()) {
$customerGroupID = $session->getCustomerGroupId();
print("Customer Group ID is ". $customerID);
} else {
echo 'Not logged In';
}
//If you are DVM set your type
if ($customerGroupID==5)
{
$type = 'dvm';
}
$types = array(
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
'dvm' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE_DVM, // dvm new account email
);
if (!isset($types[$type])) {
Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
}
if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
$this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
array('customer' => $this, 'back_url' => $backUrl), $storeId);
return $this;
}
我假设我可以在$types数组中设置不同的类型,但是如何访问常量呢
const XML\u PATH\u REGISTER\u EMAIL\u IDENTITY='customer/create\u account/EMAIL\u IDENTITY'设置新的类型条件?我还没有弄明白如何找到xml路径
编辑2/21 我复制了整个模块文件并重命名它,并将其创建为我自己的模块。我在配置文件中更改了以下内容:
<customer_create_account_email_template_dvm translate="label" module="customer">
<label>New account DVM</label>
<file>account_new_dvm.html</file>
<type>html</type>
</customer_create_account_email_template_dvm>
和修改后的功能:
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
$types = array(
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
);
if (!isset($types[$type])) {
Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
}
if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
$this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
array('customer' => $this, 'back_url' => $backUrl), $storeId);
return $this;
}
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
//Caitlin Havener
//What Group do you belong to?
if($session->isLoggedIn()) {
$customerGroupID = $session->getCustomerGroupId();
print("Customer Group ID is ". $customerID);
} else {
echo 'Not logged In';
}
//If you are DVM set your type
if ($customerGroupID==5)
{
$type = 'dvm';
}
$types = array(
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
'dvm' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE_DVM, // dvm new account email
);
if (!isset($types[$type])) {
Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
}
if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
$this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
array('customer' => $this, 'back_url' => $backUrl), $storeId);
return $this;
}
我测试了它,但它不工作。正如您所看到的,我有一些回声要跟踪,但我不确定如何直接调试它。我有Firebug,但不知道如何使用它。任何建议都将不胜感激。$session->isLoggedIn()的计算结果是否为false
2013年2月27日更新___________________________________________
@Meabed我正试图复制你在博客帖子中所做的事情。我制作了一个名为CaitlinHavener的文件夹,将DVMCustomer目录放入其中,并在其中放置了一个etc文件夹。我有config.xml在里面:
<template>
<email>
<CaitlinHavener_DVMCustomer translate="label" module="mymodule">
<label>DVMCustomer Template</label>
<file>custom/mytemplate.html</file>
<type>html</type>
</CaitlinHavener_DVMCustomer>
</email>
</template>
DVMCustomer模板
自定义/mytemplate.html
html
在system.xml中,我有:
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sections>
<customer translate="label" module="mymodule">
<groups>
<custom_email translate="label">
<label>DVM Custom Template</label>
<frontend_type>text</frontend_type>
<sort_order>5</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<exist_user_template translate="label">
<label>DVM Custom Template</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_email_template</source_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</exist_user_template>
</fields>
</custom_email>
</groups>
</customer>
</sections>
</config>
DVM自定义模板
文本
5.
1.
0
0
DVM自定义模板
选择
adminhtml/system\u config\u source\u email\u模板
3.
1.
1.
1.
我创建了一个名为CaitlinHavener_DVMCustomer.xml的模块xml,并将其放在模块文件夹中:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<CaitlinHavener_DVMCustomer>
<active>true</active>
<codePool>local</codePool>
</CaitlinHavener_DVMCustomer>
</modules>
</config>
真的
地方的
当我进入system>config>advanced时,我可以看到系统注册了模块,但当我进入system>transactional emails时,我在那里看不到模块,或者当我创建新模板并选择“load template”(加载模板)时
你知道我做错了什么吗?可以在系统->配置->中找到发送新帐户邮件的配置,然后在左侧栏中找到组客户并查找客户配置。在那里,您可以找到创建新帐户选项
就我看到的客户群而言,core Magento只允许在同一配置组中为每个storeview配置该选项。您需要制作另一个模块并扩展客户模型
class Mage_Customer_Model_Customer extends Mage_Core_Model_Abstract
该模型具有所有与发送电子邮件相关的方法,因此您需要检查客户组并设置要发送的模板。我在上面编辑过。如何找到xml路径?或者你有更好的建议吗?检查如何在XML中定义电子邮件模板,然后在修改后的文件中使用它!!你能看看我在上面做了什么,看看有什么吸引你的眼球吗?谢谢很可能xml中有错误的标记,冷静!我今天会做模块并给你发送链接:)你能看一下吗D