2

I am trying to run this install script but I am getting an exception Wrong entity ID. Tried debugging through debugger but I am not much familiar with the EAV architecture of Magento, so got lost.

Here is the portion of my config.xml

<resources>
    <namespace_mymodule_setup>
        <setup>
            <module>Namespace_Mymodule</module>
            <class>Namespace_Mymodule_Model_Resource_Eav_Mysql4_Setup</class>
        </setup>
        <connection>
            <use>core_setup</use>
        </connection>
    </namespace_mymodule_setup>
    <namespace_mymodule_write>
        <connection>
            <use>core_write</use>
        </connection>
    </namespace_mymodule_write>
    <namespace_mymodule_read>
        <connection>
            <use>core_read</use>
        </connection>
    </namespace_mymodule_read>
</resources>

I have defined the class by extending it from Mage_Eav_Model_Entity_Setup

class Namespace_Mymodule_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup {

}

And finally my install script contents are:

<?php

$installer = $this;

$installer->startSetup();

$installer->addAttribute( 'quote_payment', 'b_transaction_id', array() );
$installer->addAttribute( 'order_payment', 'b_transaction_id', array() );
$installer->addAttribute( 'invoice', 'b_transaction_id', array() );
$installer->addAttribute( 'creditmemo', 'b_transaction_id', array() );

$installer->endSetup();

What's the error about? And Its a possibility that this script ran earlier successfully from a different module (this one is a rewrite) but I am not sure if it has then how to check for that?

0

2 Answers 2

4

The whole EAV around Mage_Sales is not anymore EAV. To add new attributes "the EAV-way" you have to use the Sales Setup class, which takes carr of the flat table design.

Try to change the setup class to Mage_Sales_Model_Resource_Setup

What magento version are you using?

2
  • Awesome! It worked :) Can you also tell a bit on where it made the change in database, something that I can go checkout in the database?
    – Ashfame
    Apr 10, 2013 at 5:42
  • 3
    The affected tables should be sales_flat_quote_payment, sales_flat_order_payment, sales_flat_invoice and sales_flat_creditmemo.
    – Marius
    Apr 10, 2013 at 6:34
4

People getting this error in Magento2:

This seems to be an issue with dependency order during setup:upgrade with custom attributes. In Vendor/ModuleName/etc/module.xml, make sure to include a sequence tag for each of the modules your attributes depend on. If you're adding attributes to Products in your Setup/InstallData.php file, you need to include:

<sequence>
    <module name="Magento_Catalog" />
</sequence>

In between your module declaration

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.