Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento multiple model in a single module
 
zagodev
Jr. Member
 
Total Posts:  9
Joined:  2012-09-20
 

I got a problem loading a second model handling a database with a module.
I got 1 controller ValidateController and 2 Models Main that extends Mage_Core_Controller_Front_Action so I can’t communicate with the database, and Log that communicates with the database.

When I call $log = Mage::getModel(’modulex/log’); it is fine it gives me the correct path for with get_class($log) but when I call $log->load($params[’id’]); it fails giving me this error:

Warning: include(Companyx/Modulex/Model/Resource/Main.php[function.include]failed to open streamNo such file or directory

I don’t see why it gives me this error, it should call Resource/Log.php that exists.

I show you my config.xml

<frontend>
    <
routers>
        <
modulex>
            <use>
standard</use>
            <
args>
                <
module>Companyx_Modulex</module>
                <
frontName>modulex</frontName>
            </
args>
        </
modulex>
    </
routers>
</
frontend>
<global>
    <
models>
        <
modulex>
            <class>
Companyx_Modulex_Model</class>
            <
resourceModel>modulex_resource</resourceModel>
        </
modulex>
        <
modulex_resource>
            <class>
Companyx_Modulex_Model_Resource</class>
            <
entities>
                    <
log>
                            <
table>companyx_modulex_logs</table>
                    </
log>
            </
entities>
        </
modulex_resource>
    </
models>
</global>

Thank you for your help !

 
Magento Community Magento Community
Magento Community
Magento Community
 
zagodev
Jr. Member
 
Total Posts:  9
Joined:  2012-09-20
 

Sorry I found the solution

class Companyx_Modulex_Model_Resource_Main extends Mage_Core_Model_Resource_Db_Abstract
{
    
protected function _construct()
    
{
        $this
->_init('modulex/log''id');
    
}
}

My mistake was doing $this->_init(’modulex/main’, ‘id’);.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top