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


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:


$installer = $this;


$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() );


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?


2 Answers 2


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?

  • 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

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:

    <module name="Magento_Catalog" />

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.