Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - possible to have multiple tables for a single model?

trying to set up a config file for a custom module - do I need to have a unique model for each 'resourceModel', or is it possible to have multiple table entities per model?

Is it possible to get something like this to work:


    <config>...
 <model>
  <namespace>
    <class>Namespace_Module_Model</class>
    <resourceModel>module_mysq4</resourceModel>
  </namespace>
  <module_mysql4>
   <class>Namespace_Module_Model_Mysql4</class>
    <entities>
        <table_1>
            <table>table_1</table>
        </table_1>
        <table_2>
            <table>table_2</table>
        </table_2>
        <table_3>
            <table>table_3</table>
        </table_3>
        ...
    </entities>
   </module_mysql4>
..</config>

and then dynamically switch between the tables through the model?

and related: Anyone know what the possible children of the are and their properites? I've seen 'entities', 'associations' and 'items' - thx

like image 636
dbcn Avatar asked Oct 14 '22 20:10

dbcn


1 Answers

It's not really clear what you're asking here. Magento has a basic one resource to one table resource, and a one resource to many tables constructed in a specific manner resource for EAV style models.

The scenario you're describing above isn't directly supported by the system, but if you wanted to implement something like it there's nothing stopping you from implementing a resource that works any way you want.

As for the possible children, create the simple config viewer described here to get a dump of the entire merged config, and then use an xpath viewer to examine all the nodes (and their children) that you're interested in

like image 158
Alan Storm Avatar answered Oct 20 '22 10:10

Alan Storm