5

I searched for that information quite a while but did not found any explanation.

Many examples and tutorials for custom modules with custom database tables suggest the following for the config.xml file of corresponding module:

<resources>
    <[modulename]_setup>
        <setup>
            <module>[NAMESPACE]_[MODULENAME]</module>
            <class>Mage_Eav_Model_Entity_Setup</class>
        </setup>
        <connection>
            <use>core_setup</use>
        </connection>
    </[modulename]_setup>
    <[modulename]_write>
        <connection>
            <use>core_write</use>
        </connection>
    </[modulename]_write>
    <[modulename]_read>
        <connection>
            <use>core_read</use>
        </connection>
    </[modulename]_read>
</resources>

So my questions are:

  1. What are [modulename]_write and [modulename]_read for?
  2. What is the connection definition in [modulename]_setup for?
  3. What is <class>Mage_Eav_Model_Entity_Setup</class> for?

I ask this, because it works well with just

<resources>
    <[modulename]_setup>
        <setup>
            <module>[NAMESPACE]_[MODULENAME]</module>
        </setup>
    </[modulename]_setup>
</resources>

1 Answer 1

7

The <[modulename]_write> and <[modulename]_read> db resources are no longer required since Magento 1.4. Configuring them does no harm however, the core/resource class automatically falls back to the default_* set of db resources.
I guess most people still put them there because they follow old blog posts. The only valid reason would be if indeed a custom db connection would be configured, different from the default one, or to have your module support ancient Magento instances.

The <[modulename]_setup> resource is for using setup scripts with your module. The <class> node defines the PHP class that will execute the setup scripts found in sql/ or data/. If the <class> node is omitted, the default setup class Mage_Core_Model_Resource_Setup is used.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.