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?
Best Answer
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?