Magento eav实体设置失败-一半的表已创建,其他表未创建
我正试图设置一个自定义实体,但通过这个简单的安装脚本,Magento eav实体设置失败-一半的表已创建,其他表未创建,magento,entity-attribute-value,Magento,Entity Attribute Value,我正试图设置一个自定义实体,但通过这个简单的安装脚本,告诉我无法创建table:extended\u categories\u text。当我查看数据库时,实际上可以看到以下表格: extended_categories extended_categories_datetime extended_categories_decimal extended_categories_int 我的安装脚本非常简单,如下所示: <?php $installer = $this; $installer
告诉我无法创建table:extended\u categories\u text
。当我查看数据库时,实际上可以看到以下表格:
extended_categories
extended_categories_datetime
extended_categories_decimal
extended_categories_int
我的安装脚本非常简单,如下所示:
<?php
$installer = $this;
$installer->addEntityType('csvengine_extendedcategories',Array(
'entity_model' =>'csvengine/extendedcategories',
'attribute_model' =>'',
'table' =>'csvengine/extendedcategories',
'increment_model' =>'eav/entity_increment_numeric',
'increment_per_store' =>'0'
));
$installer->createEntityTables(
$this->getTable('csvengine/extendedcategories')
);
我遇到了同样的问题。在我的情况下,我意识到在尝试创建数据库表时发生的错误是:BLOB/TEXT列“value”在没有键长度的键规范中使用
为了强制Magento呈现我的数据库可以接受的SQL语句,我必须修改大约第1337行的app/code/core/Mage/Eav/Model/Entity/Setup.php
文件(在createEntityTables
方法中)。替换以下行:
->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')),
array('attribute_id', 'value'))
->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')),
array('entity_type_id', 'value'))
为此:
->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')),
array('attribute_id', $type == 'text' ? array('name' => 'value', 'size' => 255) : 'value'))
->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')),
array('entity_type_id', $type == 'text' ? array('name' => 'value', 'size' => 255) : 'value'))
我用这张票解决了上面的问题:
如果这不能解决您的问题,我建议进入createTable
方法中的lib/Varien/Db/Adapter/Pdo/Mysql.php
文件,并在return语句之前添加以下代码:
echo "<pre>SQL:\n$sql\n\n</pre>";
echo“SQL:\n$SQL\n\n”;
通过这种方式,您可以看到您的数据库中有哪些SQL问题,这样您就可以在SQL客户机(即phpMyAdmin)中尝试它,这将为您提供更具描述性的错误解释。在我上一篇文章之后,我在同一教程中有了一些进展,但我仍然遇到了问题。最后,我被引导到这两篇文章,这两篇文章让我完成了教程:
最后一条指出了我使用的Magento版本中的一个错误
Mage_Eav_模型_实体_设置,第1341行:
->addForeignKey($this->getFkName($eavTableName,'entity\u id','eav/entity','entity\u id'),
“实体id”,$this->getTable('eav/entity'),“实体id”,
Varien_Db_Ddl_表::动作_级联,Varien_Db_Ddl_表::动作_级联)
应该是:
->addForeignKey($this->getFkName($eavTableName,'entity\u id','eav/entity','entity\u id'),
'entity_id',$baseTableName,'entity_id',
Varien_Db_Ddl_Table::ACTION_CASCADE,Varien_Db_Ddl_Table::ACTION_CASCADE)我对1.7.0.0也有同样的问题。
我发现问题出在createEntityTables()方法的事务(第1359行)中,但我不知道为什么
因此,我只是将整个createEntityTables()方法复制到我的安装脚本中(我不想弄乱核心!),将foreach循环(第1361行)移出事务,一切正常
至于为什么beginTransaction()
会抛出异常,我不知道 您使用的是哪一个Magento版本?我使用的是最新的1.6.2.0版本。与再次发布相比,通常更倾向于使用新信息编辑您的原始帖子。仅供参考,因为DDL例程无法在MySQL中回滚。最好的方法是按照您在Alan文章中提到的那样做:扩展该方法并注释掉startTransaction()和rollBack()行。更多信息: