1

新しいユーザーがニュースレターを購読するたびに、管理者に通知メールを送信する magento 1.7 用のモジュールを作成しようとしています。これまでのところ、メールを送信することに成功しています。ただし、私のコードは、管理者に送信されるメールに表示される getEmail および getId の値を取得していません。誰かが私が間違っているところに光を当てることができれば、それは素晴らしいことです. コードは次のとおりです。

アプリ/コード/ローカル/通知/Biju/etc/config.xml

    <?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <Notify_Biju>
            <version>0.1.0</version>
        </Notify_Biju>
    </modules>
    <global>
        <models>
            <Notify_Biju>
                <class>Notify_Biju_Model</class>
            </Notify_Biju>
        </models>
        <template>
            <email>
                <newsletter_alert_template translate="label" module="n">
                    <label>Newsletter Alert to Admin</label>
                    <file>newsletter_subscription_notify.html</file>
                    <type>html</type>
                </newsletter_alert_template>
            </email>
        </template>
    </global>
    <frontend>
        <events>
            <newsletter_subscriber_save_after>
                <observers>
                    <Notify_Biju_Model_Observer>
                        <type>singleton</type>
                        <class>Notify_Biju_Model_Observer</class>
                        <method>newsletteralert</method>
                    </Notify_Biju_Model_Observer>
                </observers>
            </newsletter_subscriber_save_after>
        </events>
    </frontend>
</config>

app/code/local/Notify/Biju/Model/Observer.php

<?php

class Notify_Biju_Model_Observer {

    const XML_PATH_EMAIL_TEMPLATE = 'newsletter_alert_template';

    public function newsletteralert($observer){

            $eventname=$observer->getEvent()->getName();
            $subscriber=$observer->getEvent()->getSubscriber();
            $email=$subscriber->getEmail();
            $id=$subscriber->getId();

            $emailtemplate=Mage::getModel('core/email_template')->loadDefault(self::XML_PATH_EMAIL_TEMPLATE);
            $sender=array();
            $sender['name']="admin";
            $sender['email']="biju@talkingpebbles.com";
            try{
            $emailtemplate->sendTransactional(
                    self::XML_PATH_EMAIL_TEMPLATE,
                    $sender,
                    'biju@talkingpebbles.com, allen@compkraft.com', // email id of website/store admin
                    'admin',
                    array('subscirber'=>$subscriber)
                    );

            }
            catch(Mage_Core_Exception $e){
                // echo $e->getMessage();
                Mage::log($e->getMessage(),null,'newsletter.log');

            }

        }

}

app/etc/modules/Notify_Biju.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Notify_Biju>
            <active>true</active>
            <codePool>local</codePool>
        </Notify_Biju>
    </modules>
</config>

app/locale/en_US/template/email/newsletter_subscription_notify.html

    <!--@subject  Newsletter Subscription Alert @-->

<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>
    <td valign="top" style="padding:20px 0 20px 0">
    <!-- (header starts here) -->
    <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
    <tr>
            <td valign="top">
                <h3 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"></h3>
              </td>
              </tr>
    <tr>
      <td valign="top"><h3 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear Admin </h3>
        <p> Congratulations! A new subscriber has registered for Newsletter. Please login to the admin back-end to manage subscriptions.</p>
        <p>Subscriber Email: {{var subscriber.getEmail()}}</p>
        <p>Subscriber ID: {{var subscriber.getId()}}</p>
        <br>

    </tr>
              </table>
      </td>
              </tr>
              </table>
              </div>
</body>
4

2 に答える 2

0

タイプミスがあります:

を検索しarray('subscirber'=>$subscriber)ます。

「subscriber」のつづりを「subscirber」と間違えています

于 2013-04-01T02:59:19.777 に答える