0
votes

I'm trying to figure out why I am getting this error when my Magento module tries to install itself:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'export_sent' for key 'PRIMARY'

I think the module is trying to install itself more than once for some reason, since each time it runs, a value is inserted into sales_order_status table. The first instruction runs and then it seems like the code keeps repeating itself. Not sure what is going on. Any help is more than appreciated! BTW I did delete the value export_sent from the table before running this install.

My module's config.xml:

<config>
    <modules>
        <Millena_Export>
            <version>0.1.0</version>
        </Millena_Export>
    </modules>
    <global>
        <models>
            <millena_export>
                <class>Millena_Export_Model</class>
            </millena_export>
        </models>
        <helpers>
            <export>
                <class>Millena_Export_Helper</class>
            </export>
        </helpers>
        <resources>
            <export_setup>
                <setup>
                    <module>Millena_Export</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </export_setup>
            <export_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </export_write>
            <export_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </export_read>
        </resources>
    </global>

    <crontab>
        <jobs>
            <millena_export_send_all>
                <schedule><cron_expr>* * * * *</cron_expr></schedule>
                <run><model>millena_export/observer::exportOrderData</model></run>
            </millena_export_send_all>
        </jobs>
    </crontab>
</config>

and my sql/export_setup/mysql4-install-0.1.0.php:

$installer = $this;
$installer->startSetup();
$installer->run("
    INSERT INTO  `{$this->getTable('sales/order_status')}` (
        `status` ,
        `label`
    ) VALUES (
        'export_sent',  'Exported to Mainframe'
    );
    INSERT INTO  `{$this->getTable('sales/order_status_state')}' (
        `status` ,
        `state` ,
        `is_default`
    ) VALUES (
        'export_sent',  'processing',  '0'
    );

    INSERT INTO  `{$this->getTable('sales/order_status')}` (
        `status` ,
        `label`
    ) VALUES (
        'export_acknowledged',  'Acknowledged by Mainframe'
    );
    INSERT INTO  `{$this->getTable('sales/order_status_state')}' (
        `status` ,
        `state` ,
        `is_default`
    ) VALUES (
        'export_acknowledged',  'processing',  '0'
    );
");
$installer->endSetup();
2

2 Answers

0
votes

You say that you deleted export_sent from the table (singular), but actually in your setup script it is inserted twice, in 2 tables: did you deleted it in both tables?
Anyway, to have a better understanding of the problem, I recomend you to apply these instructions, you'll see the whole error. It involves editing app/Mage.php, so the changes will be overriden next time you upgrade your installation.
HTH

0
votes

There is an sql error, I used a single quote instead of a back tick on two lines in that script.