1

I have created custom module and model but could not insert the data into database using the model please help how to do it

config.xml


<?xml version="1.0"?>
<config>
 <modules>
 <stallioni_vendorpage>
 <version>0.1.0 
 </stallioni_vendorpage>
 </modules>
 <global>
 <models>
 <stallioni_vendorpage>
 <class>Stallioni_Vendorpage_Model</class>
 <resourceModel>vendorpage_resource</resourceModel>
 </stallioni_vendorpage>
 <vendorpage_resource>
 <class>Stallioni_Vendorpage_Model_Resource</class>
 <entities>
 <vendorpage>
 <table>vendorpage</table>
 </vendorpage>
 </entities>
 </vendorpage_resource>
 </models>
 <resources>
 <vendorpage_setup>
 <setup>
 <module>Stallioni_Vendorpage</module>
 </setup>
 <connection>
 <use>core_setup</use>
 </connection>
 </vendorpage_setup>
 <vendorpage_read>
 <connection>
 <use>core_read</use>
 </connection>
 </vendorpage_read>
 <vendorpage_write>
 <connection>
 <use>core_write</use>
 </connection>
 </vendorpage_write>
 </resources>
 <blocks>
 <vendorpage>
 <class>Stallioni_Vendorpage_Block</class>
 </vendorpage>
 </blocks>
 </global>
 <frontend>
 <routers>
 <vendorpage>
 <use>standard</use>
 <args>
 <module>stallioni_vendorpage</module>
 <frontName>vendorpage</frontName>
 </args>
 </vendorpage>
 </routers>
 <layout>
 <updates>
 <vendorpage>
 <file>vendorpage.xml</file>
 </vendorpage>
 </updates>
 </layout>
 </frontend>
</config>

model resource code


 class Stallioni_Vendorpage_Model_Resource_Vendorpage extends Mage_Core_Model_Resource_Db_Abstract
{
 protected function _construct()
 {
 $this->_init('vendorpage/vendorpage','vendorpage_id');
 //$this->_blockGroup = 'vendorpage';
 }
}

dotancohen
1,1306 silver badges21 bronze badges
asked Jun 11, 2016 at 9:31

1 Answer 1

2

You're missing the closing version tag in your config XML, but that might just be a typo when posting it here.

Your model and resource model namespace should be the same, only the resource model adds _resource to the end.

Currently your model alias is:

<models>
 <stallioni_vendorpage>

You should change it to:

<models>
 <vendorpage>

This way it will match the entity you're registering in your resource model.

answered Jun 11, 2016 at 9:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.