5

If a magento module "models" custom tables in the local Magento database, can it also be setup to "model" tables from an external database in parallel.

The config.xml global "models" tag appears to allow plural in it. So can I define a parallel 'external db connection' in resources and be able to use it with additional models, alongside the modelling of the custom tables in the local database.

Another way to rephrase this question is.. Can a magento module talk to tables in the local database and also in parallel talk to an external database using the ORM/ Model layer offered by Magento ?

    <global>
    <models>
        <(modulename)>
            <class>(ClassName_Prefix)</class>
            <resourceModel>(modulename)_(resource_model_type)</resourceModel>
            <(modulename)_(resource_model_type)>
                <!-- definition -->
            </(modulename)_(resource_model_type)>
            <rewrite><!-- definition --></rewrite>
        </(modulename)>
    </models>
    <resources>
        <(modulename)_setup><!-- definition --></(modulename)_setup>
        <(modulename)_read><!-- definition --></(modulename)_read>
        <(modulename)_write><!-- definition --></(modulename)_write>
    </resources>
1

If you don't find a solution to your problem the api functionality might work as an alternative. It's a fairly common usuage of magento so there is lot of support on here and stackoverflow. I think it could be a smoother task to develop as it should allow more flexibility with the external database in the event of changes to it and also alleviate some security risks of creating two connections inside Mage.

Some reading - Soap, Rest and Inchoo tutorial!

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.