Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installer Script gives me 'Wrong Entity ID' Magento error

I have the following installer script - when I try to run this I get the following Magento error:

Error in file: "/vagrant/site.com/public_html/app/code/local/SS/Raptor/sql/raptor_setup/install-0.0.1.php" - Wrong entity ID

My installer script is as follows:

$installer = new Mage_Eav_Model_Entity_Setup();
$installer->startSetup();

$installer->addAttribute('customer', 'organisation_id', array(
    'input'         => 'select', //or select or whatever you like
    'type'          => 'int', //or varchar or anything you want it
    'label'         => 'Organisation ID',
    'visible'       => 1,
    'required'      => 0, //mandatory? then 1
));

$installer->addAttribute('quote', 'organisation_id', array(
    'input'         => 'select', //or select or whatever you like
    'type'          => 'int', //or varchar or anything you want it
    'label'         => 'Organisation ID',
    'visible'       => 1,
    'required'      => 0, //mandatory? then 1
));

$installer->addAttribute('order', 'organisation_id', array(
    'input'         => 'select', //or select or whatever you like
    'type'          => 'int', //or varchar or anything you want it
    'label'         => 'Organisation ID',
    'visible'       => 1,
    'required'      => 0, //mandatory? then 1
));

$installer->endSetup();

Any ideas why this might be happening?

like image 889
Zabs Avatar asked Feb 14 '23 00:02

Zabs


2 Answers

You are using the wrong setup class. You could use Mage_Customer_Model_Entity_Setup to add the attributes this way. See this answer to use Mage_Eav_Model_Entity_Setup to add customer attributes.

Additional quote attributes require a different setup class. You can use Mage_Sales_Model_Resource_Setup as model here.

like image 155
Simon H Avatar answered Mar 02 '23 16:03

Simon H


Magento2 Fix:

You need to include your dependencies in your ModuleName/etc/module.xml file. I was adding a custom attribute for Products and had to include:

<sequence>
    <module name="Magento_Catalog" />
</sequence>
like image 26
sianguish Avatar answered Mar 02 '23 18:03

sianguish