Save contact form data model function

This tutorial explains how to create the model function for save contact form data to magento database. Create the following files inside as shown below.

Save contact form data model function

Copy and paste the following model codes. Please click here to find the tutorial that explains how create the full module for save contact form data to the magento database

/********** Write following code : save/contactform/contactformsave.php *******/


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

}

/********** Write following code : save/contactform/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');
    }

}

/********** Write following code : save/contactform/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');
    }
}

Share this Tutorial