0
我試圖讓this example成功註冊後發送電子郵件給管理員。 '我想,' 我有它設置正確......但究竟notta正在發生的事情:在Magento註冊成功發送管理員電子郵件
config.xml文件:
<?xml version="1.0"?>
<config>
<modules>
<WACI_CustomerExt>
<version>0.1.0</version>
</WACI_CustomerExt>
</modules>
<global>
<models>
<WACI_CustomerExt>
<class>WACI_CustomerExt_Model</class>
</WACI_CustomerExt>
</models>
<template>
<email>
<!-- regisration success -->
<notify_new_customer module="WACI_CustomerExt">
<label>Admin notification on registration success</label>
<file>notify_new_customer.html</file>
<type>html</type>
</notify_new_customer>
</email>
</template>
</global>
<frontend>
<events>
<!-- regisration success -->
<customer_register_success>
<observers>
<WACI_CustomerExt>
<type>model</type>
<class>waci_customerext/observer</class>
<method>customer_register_success</method>
</WACI_CustomerExt>
</observers>
</customer_register_success>
</events>
</frontend>
</config>
命名空間/模塊/組/ Observer.php
<?php
require_once('../../../../../Mage.php');
class WACI_CustomerExt_Model_Observer
{
public function __construct()
{
}
public function customer_register_success(Varien_Event_Observer $observer)
{
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('notify_new_customer');
$emailTemplate
->setSenderName(Mage::getStoreConfig('trans_email/ident_support/name'))
->setSenderEmail(Mage::getStoreConfig('trans_email/ident_support/email'))
->setTemplateSubject('New customer registered');
$result = $emailTemplate->send(Mage::getStoreConfig('trans_email/ident_general/email'),(Mage::getStoreConfig('trans_email/ident_general/name'), $observer->getCustomer()->getData());
}
}
本地/ EN_US /模板/ notify_new_customer.html
New customer registration:<br />
Name: {{var name}}<br />
Email: {{var email}}<br />
... you win a pickle.
有兩件事似乎有嫌疑: 我懷疑我的觀察者在我的配置中正確設置。 我期望我需要包含app/mage.php(但它在示例中沒有這樣做)。
我在日誌中沒有發現任何錯誤,所以我假設事件沒有得到註冊或正確處理。
無論如何,在典型的Magento窗體中,我的嘗試無法正常工作。
我會很感激一些建議; d
乾杯
您不需要包含app/mage.php,因爲這已經在/index.php中完成了。我會將日誌記錄添加到'customer_register_success'函數中以確定它是否正常工作......如果不是,那麼您沒有正確配置它。如果是這樣,那麼其他事情就會發生在 – CCBlackburn
啊 - 是的。不需要包括法師。最近Ajax太多了。 - 我一直在檢查日誌,但是在某個時候拿出來了。重新加入,它肯定指向包含錯誤。謝謝。 – Bosworth99
@CCBlackburn =好吧,我現在收到一封電子郵件,但該模板沒有被讀取或處理。無論如何,電子郵件的內容都是空的。任何想法? – Bosworth99