Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento eav实体设置失败-Can';不创建表_Magento_Entity Attribute Value - Fatal编程技术网

Magento eav实体设置失败-Can';不创建表

Magento eav实体设置失败-Can';不创建表,magento,entity-attribute-value,Magento,Entity Attribute Value,我试图在Magento 1.7.0.0中设置一个自定义实体,如下所示,但通过这个简单的安装脚本,它告诉我“无法创建表:eavblog_posts” 我的安装脚本非常简单,如下所示: <?php $installer = $this; $installer->addEntityType('complexworld_eavblogpost', Array( 'entity_model'=>'complexworld/eavblogpost', 'attribute_model'=&

我试图在Magento 1.7.0.0中设置一个自定义实体,如下所示,但通过这个简单的安装脚本,它告诉我“无法创建表:eavblog_posts”

我的安装脚本非常简单,如下所示:

<?php
$installer = $this;
$installer->addEntityType('complexworld_eavblogpost',
Array(
'entity_model'=>'complexworld/eavblogpost',
'attribute_model'=>'',
'table'=>'complexworld/eavblogpost',
'increment_model'=>'',eav/entity_increment_numeric
'increment_per_store'=>'0'
));
$installer->createEntityTables(
$this->getTable('complexworld/eavblogpost')
);

首先,这行是错误的:

'increment_model'=>'',eav/entity_increment_numeric
它需要在引号内

未能确认最新版本的安装程序功能中存在一些错误

使用phpMyAdmin或类似工具进入数据库,检查是否有任何表已经存在。如果有,请删除它们。同时删除core_资源中的模块记录

再试一次

还有一个步骤我想都想不起来了(我知道这很有用,但今晚我会试着记住并编辑它)

创建表后,如果查看类型表(int、text char等)的外键分配,您会注意到entity_id字段正在查看eav_entity.entity_id。这需要更改为eavblogpost_entity表

您可能还注意到,当所有外键引用都是INT(10)时,eavblogpost_entity.entity_id字段是INT(11)。手动将eavblogpost_entity.entity_id字段更改为INT(10)

解决所有这些问题的唯一方法是使用有效的函数重写createEntityTables()函数,或者手动创建所有表。这里有一个很好的资源来帮助您完成这一部分


在你走的时候把这些都弄得乱七八糟,我相信你会在你不得不做的那一步上绊倒,我已经忘记了。对不起

在我的例子中,问题是由于Magento 1.7/1.12中的
createEntityTables()
方法的错误造成的

在中,Magento团队建议注释lib/Varien/Db/Adapter/Pdo/Mysql.php中的第417行:

$this->_checkDdlTransaction($sql);
相反,我会推荐以下两种方法

1) 将
createEntityTables()
方法复制到您自己的文件(您的/Module/Model/Resource/Setup.php)并注释掉事务方法

2) 编写抽象查询以保留事务:

// Example of MySQL API
/**
 * Create table array('catalog/product', 'decimal')
 */
$table = $installer->getConnection()
    ->newTable($installer->getTable(array('catalog/product', 'decimal')))
    ->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity'  => true,
        'nullable'  => false,
        'primary'   => true,
        ), 'Value ID')
    ->addColumn(...

对不起,我认为节目评论不清楚。代码如下:'increment\u model'=>'','increment\u per\u store'=>'0',我将尝试为您提供答案,非常感谢您,绝对没有理由选择#2#1是很好的,因为2也不会给你交易…:(代码在1.9中有所不同,我必须删除eav_entity_类型中的FK。)