0

I have a contact form that is set up so that the form information is emailed to an email address, like any form on the internet. However does anyone know if possible to save the contact forms in Magento?

  • are you asking like magento default contact us page ? – Baby in Magento Jun 15 '16 at 9:54
  • I think they use the default contact us page, but I wanted to know if it was possible to save the contact forms in Magento. As I cant seem to see a module. – Rob B Jun 15 '16 at 10:04
  • Magento does not offer this by default, you would have to write a custom module. – Fabian Schmengler Jun 15 '16 at 10:27
1

There is no core functionality for this, though adding it shouldn't be too difficult as you'd just have to replace the controller action with your own controller and persist the information into the database. A quick search of magento-connect shows at least one results (Keep Contacts) though it is paid, I'd be surprised if it's the only module on there though. I'm not sure what the rules are with regards to advertising extensions, so I won't link to it (though I have no association with the module or it's developer, so I can't attest to the quality).

-1

Please create module and rewrite the postaction function of the controller.

$model = Mage::getModel("contactform/contactformsave");
            $model->setData(array('created_at'=>NOW(),'name'=>$post['name'],
                'email'=>$post['email'],'telephone'=>$post['telephone'],
                'comment'=>$post['comment']));
            $model->save();

            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('*/*/');

Please add following code in the config file.

<global>
    <rewrite>
        <customcontactus>
            <from><![CDATA[#^/contacts/index/#]]></from>
            <to>/contactform/index/</to>
        </customcontactus>
    </rewrite>
</global>

Click here full code and the file structure.Please create the custom model classes as shown below.

/* save/contactform/model/contactformsave.php *******/
class Save_Contactform_Model_Contactformsave extends Mage_Core_Model_Abstract
 {
  public function _construct()
 {
    $this->_init('contactform/contactformsave');
}

}

/*  save/contactform/model/resource/contactformsave.php ************/

 class Save_Contactform_Model_Resource_Contactformsave extends Mage_Core_Model_Resource_Db_Abstract
{
 /***
  * Initialize resource model
  */

 public function _construct()
 {
    $this->_init('contactform/contactformsave','contact_id');
}

 }

 /* save/contactform/model/resource/contactformsave/collection.php ******/
 <?php
class Save_Contactform_Model_Resource_Contactformsave_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
protected function _construct()
{
    $this->_init('contactform/contactformsave');
}
}

http://www.pearlbells.co.uk/save-contact-form-data-magento-database/

  • To make this answer complete, you will need to add more information from the linked article(s). It doesn't have to be the full code, but you don't even mention that a model has to be created. Giving a link for more detailed information is good, but answers on Stack Exchange should still be useful when a link becomes dead. – Fabian Schmengler Mar 18 '17 at 23:34
  • I have added the model details as well . Also check my blog for full code – Liz Eipe C Mar 20 '17 at 0:44

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.