1

The feedback form should be sent to the mail that you specified in the admin in the module settings and to a specific template. Now the form sends data similar to the form from the page, "contact us". How to make so that sending would be on your own letter template?

system.xml

<?xml version="1.0"?>
<config>
    <tabs>
        <general translate="label" module="feedback">
            <label>general</label>
            <sort_order>1</sort_order>
        </general>
    </tabs>
    <sections>
        <feedback_setting module="feedback" translate="label">
            <label>Feedback</label>
            <tab>general</tab>
            <frontend_type>text</frontend_type>
            <sort_order>9999</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <captcha translate="label">
                    <label>Captcha</label>
                    <expanded>1</expanded>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_Website>1</show_in_Website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <blocks_captcha_secret>
                            <label>Secret key</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_Website>1</show_in_Website>
                            <show_in_store>1</show_in_store>
                        </blocks_captcha_secret>
                        <blocks_captcha_public>
                            <label>Public key</label>
                            <frontend_type>text</frontend_type>
                            <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>
                        </blocks_captcha_public>
                    </fields>
                </captcha>
                <email translate="label">
                    <label>Email Options</label>
                    <expanded>1</expanded>
                    <frontend_type>text</frontend_type>
                    <sort_order>50</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <recipient_email translate="label">
                            <label>Send Emails To</label>
                            <frontend_type>text</frontend_type>
                            <validate>validate-email required-entry</validate>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </recipient_email>
                        <email_template translate="label">
                            <label>Email Template</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_email_template</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </email_template>
                    </fields>
                </email>
            </groups>
        </feedback_setting>
    </sections>
</config>

IndexController.php

(Here you are sending to the mail!)

Constants are pulled from the class assistant

const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';

    $post = array_merge($post, $data);
                            $postObject = Mage::getModel('feedback/block');
                            $postObject->setData($post);
                            $postObject->save();
                            $mailTemplate = Mage::getModel('core/email_template');
                            /* @var $mailTemplate Mage_Core_Model_Email_Template */
                            $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                                ->setReplyTo($email)
                                ->sendTransactional(
                                    Mage::getStoreConfig($paths::XML_PATH_EMAIL_TEMPLATE),
                                    Mage::getStoreConfig($paths::XML_PATH_EMAIL_SENDER),
                                    Mage::getStoreConfig($paths::XML_PATH_EMAIL_RECIPIENT),
                                    null,
                                    array('data' => $postObject,
                                        'feedback_id' => $postObject->getId(),
                                    )
                                );
                            if (!$mailTemplate->getSentSuccess()) {
                                throw new Exception();
                            }

                            $translate->setTranslateInline(true);
                            Mage::getSingleton('core/session')->addSuccess('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.');
                            $this->_redirect('*/*/');
                            return;

Template

    <!--@subject Feedback form@-->
    <!--@vars
    {"var data.feedback_id":"Sender Feedback id",
    {"var data.subject":"Sender Subject",
    "var data.name":"Sender Name",
    "var data.email":"Sender Email",
    "var data.phone":"Sender Phone",
    "var data.user_agent":"Sender User agent",
    "var data.remote_ip":"Sender Remote ip",
    "var data.created_at":"Sender Created at",
    "var data.message":"Message"}
    @-->
    Feedback id: {{var data.feedback_id}}<br>
    Subject: {{var data.subject}}<br>
    Name: {{var data.name}}<br>
    Email: {{var data.email}}<br>
    Telephone: {{var data.phone}}<br>
    User agent: {{var data.user_agent}}<br>
    Remote ip: {{var data.remote_ip}}<br>
    Created at: {{var data.created_at}}<br>

    Message: {{var data.message}}

config.xml

<email>
                <custom_template>
                    <label>Feedback template</label>
                    <file>feedback_form.html</file>
                    <type>html</type>
                </custom_template>
            </email>

What needs to be changed to apply my module settings, rather than settings from the "contacts" block?

1

You need to change the const variable as currently its taking contact email setting as place of feedback section configuration setting

so change below code

const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email'; 
const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity'; 
const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';

with below code

const XML_PATH_EMAIL_RECIPIENT = 'feedback_setting/email/recipient_email'; 
const XML_PATH_EMAIL_SENDER = 'feedback_setting/email/sender_email_identity'; 
const XML_PATH_EMAIL_TEMPLATE = 'feedback_setting/email/email_template';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.