3

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?

3 Answers 3

2

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>
1
  • 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, 2013 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>
0

The answer from binici is correct even for Magento 2. Here is an example Magento 2 etc/module.xml file that accomplishes the same goal. This file declares a module called "Foo_Bar" with version "1.0.0" and states that it depends on module "Foo_Charlie":

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Foo_Bar" setup_version="1.0.0">
        <sequence>
            <module name="Foo_Charlie" />
        </sequence>
    </module>
</config>

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.