1

I'm trying to add values for each store using an configuration setup script but for some reason the script runs but doesn't set any values and I'm running out of ideas why??

Here's my config scrip

$installer = $this;

$this->startSetup();

$this->setConfigData(' modulename/order/prefix/', 'A', 'stores', 1);

$this->endSetup();

Here's my system.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <sections>
        <namespace_modulename translate="label" module="namespace_modulename">
            <label>Module Name</label>
            <tab>sales</tab>
            <frontend_type>text</frontend_type>
            <sort_order>100</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <order translate="label" module="namespace_modulename">
                    <label>Label</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <prefix translate="label comment">
                            <label>Text</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </prefix>
                        <padding_length translate="label comment">
                            <label>Numeric</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>40</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </padding_length>
                    </fields>
                </order>
            </groups>
        </namespace_modulename>
    </sections>
</config>

my config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Namespace_Modulename>
            <version>1.0.1</version>
        </Namespace_Modulename>
    </modules>
    <global>
        <models>
            <namespace_customordernumber>
                <class>Namespace_Modulename_Model</class>
            </namespace_customordernumber>
            <eav>
                <rewrite>
                    <entity_type>Namespace_Modulename_Model_Eav_Entity_Type</entity_type>
                </rewrite>
            </eav>
        </models>
        <resources>
            <customerordernumber>
                <setup>
                    <module>Namespace_Modulename</module>
                    <class>Namespace_Modulename_Model_Resource_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customerordernumber>
            <customerordernumber_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </customerordernumber_write>
            <customerordernumber_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </customerordernumber_read>
        </resources>
        <helpers>
            <namespace_customordernumber>
                <class>Namespace_Modulename_Helper</class>
            </namespace_customordernumber>
        </helpers>
    </global>
</config>

I have also added a Model/Resource/Setup.php class

3

Let's start from the beginning:

Namespace_Modulename/etc/config.xml:

<?xml version="1.0" encoding="uft-8"?>
<config>
    <modules>
        <Namespace_Modulename>
            <!-- check core_resource table, make sure the version there either doesn't exist, or is lower than 1.0.1 -->
            <version>1.0.1</version>
        </Namespace_Modulename>
    </modules>
    ...
    <global>
        <models>
            <namespace_modulename>
                <class>Namespace_Modulename_Model</class>
            </namespace_modulename>
        </models>
        <resources>
            <!-- I think the _setup suffix is important -->
            <customerordernumber_setup>
                <setup>
                    <module>Namespace_Modulename</module>
                    <!-- class should eventually inherit from Mage_Core_Model_Resource_Setup -->
                    <class>Namespace_Modulename_Model_Resource_Setup</class>
                </setup>
            </customerordernumber_setup>
        </resources>
    </global>
    ...
</config>

Obviously, the resource class must exists; Namespace_Modulename/Model/Resource/Setup.php:

class Namespace_Modulename_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
{
    ...

And the upgrade script itself, Namespace_Modulename/sql/customerordernumber_setup/upgrade-1.0.0-1.0.1.php:

$installer = $this;

$this->startSetup();
// your path is wrong: no namespace prefix, starts with a space and has a trailing slash
// $this->setConfigData(' modulename/order/prefix/', 'A', 'stores', 1);
$this->setConfigData('namespace_modulename/order/prefix', 'A', 'stores', 1);
$this->endSetup();

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.