duandian8110 2013-08-12 18:32
浏览 55
已采纳

Magento更改表单的电子邮件地址

I bought a magento based website some days ago. There is a form in the page website.com/service
the actual code in the backend is:

{{block type="core/template" name="serviceForm" form_action="/contacts/index/service" template="contacts/form_service.phtml"}}

and in the front-end it is

<form method="post" id="contactForm" action="/contacts/index/service">

It is not exactly a contact form but contact form with lots of additional parameters.
What I want to do is edit the email address the form is submitted to.

If the form action was /contacts/index/post/ I could have edited the file at

/app/code/core/Mage/Contacts/controllers/IndexController.php 

But I am unable to find any file where I can edit for /contacts/index/service . I think that the form is working as it tells me

Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.

after redirecting me to a certain page after form submission.
So I basically want to edit the email and need your help to find the location of the file.

@aynber located the function for me but I can't seem to find the email.

public function serviceAction()
    {
        $post = $this->getRequest()->getPost();
        if ( $post ) {
            $translate = Mage::getSingleton('core/translate');
            /* @var $translate Mage_Core_Model_Translate */
            $translate->setTranslateInline(false);
            try {
                $postObject = new Varien_Object();
                $postObject->setData($post);

                $error = false;

                if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
                    $error = true;
                }

                if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
                    $error = true;
                }

                if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                    $error = true;
                }

                if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                    $error = true;
                }

                if ($error) {
                    throw new Exception();
                }
                $mailTemplate = Mage::getModel('core/email_template');
                /* @var $mailTemplate Mage_Core_Model_Email_Template */
                $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                    ->setReplyTo($post['email'])
                    ->sendTransactional(
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                        null,
                        array('data' => $postObject)
                    );

                if (!$mailTemplate->getSentSuccess()) {
                    throw new Exception();
                }

                $translate->setTranslateInline(true);

                Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
                $this->_redirect('*/*/');

                return;
            } catch (Exception $e) {
                $translate->setTranslateInline(true);

                Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
                $this->_redirect('*/*/');
                return;
            }

        } else {
            $this->_redirect('*/*/');
        }
    }
  • 写回答

2条回答 默认 最新

  • drus39136 2013-08-12 18:37
    关注

    It should still be in that file, it will just be function serviceAction() inside of IndexController.php. If it's not there, see if there is a corresponding IndexController.php somewhere inside of the app/code/local directory. Often the forms pull from an email address set in the System configuration under Contacts.

    EDIT

    The line you're looking to change is

    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
    

    That address is pulled from the system configuration. You can hardcode the email address, or set it to another configured email address.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改