0

I need to insert a form into one tab contained into product page.
you can see an example in this page

I created a static block that contain the form, the action is a cms page.

so, I need to insert a php function that send me the data insert into the form.

How can I do this action?

closed as too broad by sv3n, Jai, Dhiren Vasoya, Priyank, Piyush Nov 2 '18 at 6:01

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Set your action of form as

<form action="<?php echo $this->getUrl('module/controller/method'); ?>" >

Then create a controller with the corresponding method.

function Name(){
if ($data = $this->getRequest()->getPost()) {

    $model = Mage::getModel('module/model_name');
    $model->setData($data);
    try {
        $model->save();
    }catch (Exception $e) {
        $this->_forward('NoRoute');
    }
}

To send email do following

$translate = Mage::getSingleton('core/translate');

            /* @var $translate Mage_Core_Model_Translate */

            $translate->setTranslateInline(false);

            try {               

                $postObject = new Varien_Object();

                $postObject->setData($data);

                $mailTemplate = Mage::getModel('core/email_template');

                /* @var $mailTemplate Mage_Core_Model_Email_Template */

                $mailTemplate->setDesignConfig(array('area' => 'frontend'))                 
                    ->sendTransactional(
                        'test_email_template',
                        'general',
                        'receiver_email_id', null, array('data' => $postObject)
                    );

                $translate->setTranslateInline(true);

            } catch (Exception $e) {

                $translate->setTranslateInline(true);

            }
  • thanks for the reply, I need to insert the php function mail and can you explain well your solution please? I'm a magento newbie :( – Mma87 Jul 2 '14 at 14:25
  • You can use zend mail function for your magento form. – Ann Mary Jul 3 '14 at 9:12
0

Try this

try{
    $mail = new Zend_Mail();
    $mail->setFrom("fromemail","fromname");
    $mail->addTo("toemail","toname");
    $mail->setSubject("subject");
    $mail->setBodyHtml(" body text"); 
    $mail->send();
}catch(Exception $e){
    echo $e->getMassage(); 
}

Hope,It may work for you..

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