I have this global config:
<global>
<models>
<subscriber>
<class>Giftlab_Subscriber_Model</class>
<resourceModel>subscriber_resource</resourceModel>
</subscriber>
<subscriber_resource>
<class>Giftlab_Subscriber_Model_Resource</class>
<entities>
<records>
<table>subscriber_records</table>
</records>
</entities>
</subscriber_resource>
</models>
<resources>
<giftlab_subscriber_write>
<connection>
<use>core_write</use>
</connection>
</giftlab_subscriber_write>
<giftlab_subscriber_read>
<connection>
<use>core_read</use>
</connection>
</giftlab_subscriber_read>
<giftlab_subscriber_setup>
<setup>
<module>Giftlab_Subscriber</module>
<class>Giftlab_Subscriber_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</giftlab_subscriber_setup>
</resources>
</global>
in my mysql4-install-0.1.0.php file, I need to get the table name. How do I do it? I know it is something like this:
$this->getTable('subscriber_resource/records')
But that only produces an exception Can't retrieve entity config: subscriber_resource/records
. What do I need to do to retrieve the table name?
Figured out the answer myself, although thanks to @Yaroslav for directing my to Alan Storm's tutorial, as that helped.
The answer is, I need this:
$this->getTable('subscriber/records');
where "subscriber" is the name of the config entry for the model (not the resource), and "records" is the entity. Turns out that when magento parses thinga/thingb, it always assumes that thinga before the slash is the model and dereferences that to get the resource, by looking in the config for <thinga><resourceModel>{resourcemodel}
, and then looking again for <{resourcemodel}><entities><thingb><table>
to get the table name.
So my config was correct, I was just getting confused between the idea of model and resource. Hope this helps someone else getting stuck on the same problem - I couldn't find any clear info on this in the various tutorials.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With