0

さて、シナリオは次のとおりです。

Magento インストールにアフィリエイト プログラムがあります。「クーポン コード リマインダーを送信する」ボタンを作成しました...何だと思います...アカウントのメールにクーポン コード リマインダーを送信します。テンプレートを作成しました / このテンプレートを使用して送信されるメールがあります。

ただし、モジュールに構成オプションを追加して、カスタム テンプレートを許可したいと考えています。他の場所と同じように。他の場所で見たものをコピーしようとしましたが、うまくいきません。何か助けはありますか?

構成.xml:

<config>
<global>
    <template>
        <email>
            <coupon_code_reminder_email_template translate="label" module="adminhtmlext">
                <label>Coupon Code Reminder</label>
                <file>adminhtmlext/coupon_code_template.html</file>
                <type>html</type>
            </coupon_code_reminder_email_template>
        </email>
    </template> 
</global>
</config>

System.xml (抜粋):

            <fields>
                <coupon_code_reminder_email_template translate="label">
                    <label>Coupon Reminder Template</label>
                    <frontend_type>select</frontend_type>
                    <source_model>adminhtml/system_config_source_email_template</source_model>
                    <sort_order>20</sort_order> 
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                </coupon_code_reminder_email_template>
            </fields>   

インストール-0.1.0.php:

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */

$configValuesMap = array(
  'coupon_code/reminder/email_template' =>
  'coupon_code_reminder_email_template',
);

foreach ($configValuesMap as $configPath=>$configValue) {
    $installer->setConfigData($configPath, $configValue);
}

EmailController.php:

class Blizzardlabs_Adminhtmlext_EmailController extends Mage_Core_Controller_Front_Action
{

    const EMAIL_TEMPLATE_XML_PATH = 'coupon_code/reminder/email_template';

    public function sendAction()
    {
        /**
         * $templateId can be set to numeric or string type value.
         * You can use Id of transactional emails (found in
         * "System->Trasactional Emails"). But better practice is
         * to create a config for this and use xml path to fetch
         * email template info (whatever from file/db).
         */
        $request = $this->getRequest()->getParams();
        $templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH);        

        $mailSubject = 'Levalast.com Coupon Code Reminder';

        /**
         * $sender can be of type string or array. You can set identity of
         * diffrent Store emails (like 'support', 'sales', etc.) found
         * in "System->Configuration->General->Store Email Addresses"
         */
        $sender = Array(
            'name' => 'Levelast Support',
            'email' => 'referral@levelast.com'
        );

        /**
         * In case of multiple recipient use array here.
         */
        $email = $request['email'];

        /**
         * If $name = null, then magento will parse the email id
         * and use the base part as name.
         */
//        $name = 'Bill Garrison';

        $vars = Array('coupon_code' => $request['code']);
        /* An example how you can pass magento objects and normal variables */
        /*
          $vars = Array('customer'=>$customer,
          'address' =>$address,
          'varification_data'=>'fake data for example'); */

        /* This is optional */
        $storeId = Mage::app()->getStore()->getId();

        $translate = Mage::getSingleton('core/translate');
        Mage::getModel('core/email_template')
            ->setTemplateSubject($mailSubject)
            ->sendTransactional($templateId, $sender, $email, null, $vars, $storeId);
        $translate->setTranslateInline(true);
    }

}

したがって、デフォルトのテンプレートを使用してメールを送信できます...そして、構成オプションでテンプレートを変更するオプションが表示されます。ただし、そのオプションを変更しても何も起こりません。デフォルトのテンプレートを引き続き使用します。何か助けはありますか?

4

1 に答える 1