2

What is the best way to deal with site configurations when building a site?

I am currently religiously using upgrade and install scripts for everything, meaning a zero configuration state when moving a site betweene environments etc.

However, some things in Magento just dont lend themselves to upgrade scripts and it is starting to become a little bit messy.

An example, is i am using the webshopapps matrix rate module and am writing an install script for my site that creates the required entries in the webshopapps shipping rate table.

However, in order to get that to work, i need to make my sites local module depend on the webshopapps module.

Really what I am asking here is what are the best practices for developing like this?

1

I would create a local extension that you would use for rewriting classes from other extensions, writing update scripts and call it something like XyzCore. This way you ensure having this kind of logic in one place.

You may also specify in your module-xml that it depends on other extensions. Here is an example taken from Mage_Api.xml:

<config>
    <modules>
        <Mage_Api>
            <active>true</active>
            <codePool>core</codePool>
            <depends>
                <Mage_Core />
            </depends>
        </Mage_Api>
    </modules>
</config>
  • How does this extend to setting up your http url vs https url, etc.? I think that's what the OP is getting at... – philwinkle May 6 '13 at 20:11
0

As binici says.

I implement a ProjectName_Install module and throw in all the stuff which should be configurated. What can be easily done is the configuration. Consider everything inside the <default>.

All other things are going into install scripts. If you need MatrixRates sure, just throw it in the depends, I don't see any problem with that.

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Projectname_Install>
            <version>0.1.20</version>
        </Projectname_Install>
    </modules>
    <global>
        <resources>
            <projectname_install>
                <setup>
                    <module>Projectname_Install</module>
                    <class>Mage_Eav_Model_Entity_Setup</class>
                </setup>
            </projectname_install>
        </resources>
        <helpers>
            <projectname_install>
                <class>Projectname_Install_Helper</class>
            </projectname_install>
        </helpers>
    </global>
    <default>
        <design>
            <header>
                <logo_src>images/logo.png</logo_src>
                <logo_alt>Some text</logo_alt>
                <welcome>Herzlich Willkommen bei xxx</welcome>
            </header>
            <package>
                <name>projectname</name>
            </package>
            <theme>
                <default>projectname</default>
            </theme>
        </design>
        <admin>
            <security>
                <session_cookie_lifetime>86000</session_cookie_lifetime>
            </security>
        </admin>
        <catalog>
            <seo>
                <product_url_suffix />
                <category_url_suffix />
            </seo>
        </catalog>
        <cms>
            <wysiwyg>
                <enabled>hidden</enabled>
            </wysiwyg>
        </cms>
        <customer>
            <startup>
                <redirect_dashboard>0</redirect_dashboard>
            </startup>
            <address>
                <prefix_options>Herr;Frau</prefix_options>
            </address>
        </customer>
        <region>
            <state_required />
        </region>
        <sales>
            <reorder>
                <allow>0</allow>
            </reorder>
        </sales>
        <cataloginventory>
            <item_options>
                <manage_stock>0</manage_stock>
            </item_options>
        </cataloginventory>
    </default>
</config>

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.