Home Ask Login Register

Developers Planet

Your answer is one click away!

zomato February 2016

Value not getting bind in the Magento controller

This is the predefined post function inside Magento controller.

public function postAction()
    $post = $this->getRequest()->getPost();

    if ( $post ) {
        $translate = Mage::getSingleton('core/translate');
        /* @var $translate Mage_Core_Model_Translate */
        try {
            $postObject = new Varien_Object();

            $error = false;

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

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


            if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                $error = true;
            if (!Zend_Validate::is(trim($post['producturl']) , 'NotEmpty')) {
                $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'))
                    array('data' => $postObject)

            if (!$mailTemplate->getSentSucces        


Andre Ferraz February 2016

Well if you wish add the product URL to the email you first need to get the product key and wrap it around the static getUrl function.


Next just assign the above code to a variable and use some jQuery / Javascript to append the url to the end of the content of the message body. Honestly I would not recommend you to do this.

b.enoit.be February 2016

So, the emails templates are html files that you can actually find in the folder app/locale/[some_locale]/template/ if your locale is english of the US then some_locale will be en_US, if that is french from Belgium, then it will be fr_BE, so that is the language code on 2 letter as defined by ISO 639-1 then an underscore _ and country code as defined by ISO 3166-1 alpha-2.

And the name of the file will be something you could find if you do a global search on the handle of the template you actually stated in you comment.

So here contacts_email_email_template is actually defined in app/code/core/Mage/Contacts/etc/config.xml as being the file contact_form.html :

        <contacts_email_email_template translate="label" module="contacts">
            <label>Contact Form</label>

So if you go and edit app/locale/en_US/template/email/contact_form.html that I reproduced here bellow and in which I added your product url value, that should work :

<!--@subject Contact Form@-->
{"var data.name":"Sender Name",
"var data.email":"Sender Email",
"var data.telephone":"Sender Telephone",
"var data.comment":"Comment"}
Name: {{var data.name}}
Email: {{var data.email}}
Telephone: {{var data.telephone}}

Comment: {{var data.comment}}
<!-- this bellow line is actually what you are after -->
Product URL : {{var data.producturl}}

data, actually being the key of the array y

Post Status

Asked in February 2016
Viewed 2,201 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life