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?

asked Apr 9, 2013 at 23:18
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?

answered Apr 9, 2013 at 23:52
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? Commented 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. Commented 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

answered Jul 26, 2017 at 14:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.