It looks like the problem is related to a missing unique index -_-
try adding a unique index to your entity tables(_int, _varchar, _decimal, ....) over following cols
entity_id, attribute_id, store_id
after i added these one it worked for me
if you want to fix your install script:
you will need to create/update you Setup Class
the problem is in the Mage_Eav_Model_Entity_Setup::createEntityTables
function which is missing the unique indexes. copy that function into your setup class and add
->addIndex(
$this->getIdxName(
$eavTableName,
array('entity_id', 'attribute_id', 'store_id'),
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
),
array('entity_id', 'attribute_id', 'store_id'),
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE));
into the creation statement of the eav_tables.
after that the foreach loop that creates the eav tables should look like this:
/**
* Create table array($baseTableName, $type)
*/
foreach ($types as $type => $fieldType) {
$eavTableName = array($baseTableName, $type);
$eavTable = $connection->newTable($this->getTable($eavTableName));
$eavTable
->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
), 'Value Id')
->addColumn('entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Entity Type Id')
->addColumn('attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Attribute Id')
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Store Id')
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Entity Id')
->addColumn('value', $fieldType[0], $fieldType[1], array(
'nullable' => false,
), 'Attribute Value')
->addIndex($this->getIdxName($eavTableName, array('entity_type_id')),
array('entity_type_id'))
->addIndex($this->getIdxName($eavTableName, array('attribute_id')),
array('attribute_id'))
->addIndex($this->getIdxName($eavTableName, array('store_id')),
array('store_id'))
->addIndex($this->getIdxName($eavTableName, array('entity_id')),
array('entity_id'))
->addIndex(
$this->getIdxName(
$eavTableName,
array('entity_id', 'attribute_id', 'store_id'),
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
),
array('entity_id', 'attribute_id', 'store_id'),
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE));
if ($type !== 'text') {
$eavTable->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')),
array('attribute_id', 'value'));
$eavTable->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')),
array('entity_type_id', 'value'));
}
$eavTable
->addForeignKey($this->getFkName($eavTableName, 'entity_id', $baseTableName, 'entity_id'),
'entity_id', $this->getTable($baseTableName), 'entity_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
->addForeignKey($this->getFkName($eavTableName, 'entity_type_id', 'eav/entity_type', 'entity_type_id'),
'entity_type_id', $this->getTable('eav/entity_type'), 'entity_type_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
->addForeignKey($this->getFkName($eavTableName, 'store_id', 'core/store', 'store_id'),
'store_id', $this->getTable('core/store'), 'store_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
->setComment('Eav Entity Value Table');
$tables[$this->getTable($eavTableName)] = $eavTable;
}
If you have already created the entity and you dont want to reinstall/drop the tables, try something like this untested
//your entity types
$entityTypes = array('datetime', 'decimal', 'int', 'text', 'varchar');
foreach($entityTypes AS $type){
$connection->addIndex(
$this->getTable('loremipsum/lorem') . '_' . $type,
$installer->getIdxName(
$eavTableName,
array('entity_id', 'attribute_id', 'store_id'),
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
),
array('entity_id', 'attribute_id', 'store_id'),
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
);
}