2012-05-08 4 views
4

Magento 1.7.0.0에서 alan storms article about it 다음에 사용자 지정 엔티티를 설정하려고하는데이 간단한 설치 스크립트로 "테이블을 만들 수 없음 : eavblog_posts ".Magento eav 엔티티 설치 실패 - 테이블을 만들 수 없음

는 스크립트가 deadsimple과 같이 보입니다 설치 내 :

<?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') 
); 

스크립트 내 작업 설치를 어떻게받을 수 있나요? 이것은 알려진 magento 버그입니까? 모든

답변

1

먼저,이 라인은 잘못된 것입니다 :

'increment_model'=>'',eav/entity_increment_numeric 

은 따옴표 안에 있어야합니다.

최신 버전의 설치 관리자 기능에 몇 가지 버그가 있다는 데 실패했습니다.

phpMyAdmin 또는 이와 유사한 도구를 사용하여 데이터베이스에 들어가서 이미 존재하는 테이블이 있는지 확인하십시오. 삭제 한 경우 삭제하십시오. 또한 core_resource에서 모듈의 레코드를 삭제하십시오.

다시 시도하십시오.

다음은 여기에 한 단계가 있습니다. 머리 꼭대기를 기억할 수 없습니다 (유용합니다. 알아요.하지만 오늘 밤 기억하고 수정 해 봅니다).

일단 테이블이 작성되면 유형 테이블 (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() 함수를 작동하는 것으로 대체하거나 모든 테이블을 수동으로 만드는 것입니다. 이 부분을 통해 당신을 도울 수있는 좋은 자료가 있습니다. http://inchoo.net/ecommerce/magento/creating-an-eav-based-models-in-magento/

당신이 가면서이 모든 것들을 뒤적 거리며 나는 잊어 버린 단계를 넘어서게 될 것입니다. 죄송합니다! 내 경우

+0

미안 해요, 난 프로그램이 코멘트 생각하는 것은 명확하지 않다.코드는 다음과 같습니다 'increment_model'=> '', 'increment_per_store'=> '0', 답변을 제공해 드리겠습니다. 감사합니다. –

5

이 문제가 젠토에서 createEntityTables() 방법 버그로 인해이었다 1.7/1.12

their answer to this bug report에서 젠토 팀에서 라인 (417) 주석 추천 lib 디렉토리/Varien/DB/어댑터/PDO/Mysql.php는 대신

$this->_checkDdlTransaction($sql); 

, 당신의 자신의 파일 (사용자/모듈/모델/자원/Setup.php가)와 공동으로 createEntityTables() 방법을 복사 the advice in Zachary Schuessler's post 및 중

1

를) 다음 추천 거래를 유지하기 위해 추상화 된 쿼리를 작성하는 거래 방법 ...

또는

2

)를 밖으로 mmenting :

// 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(... 
+0

Afaics, # 2를 선택해야 할 이유가 전혀 없습니다. # 1은 # 2가 당신에게 트랜잭션을주지 않는다고해도 괜찮습니다. : – jmlnik

+0

코드가 1.9와 다르며, eav_entity_type에서 FK를 삭제해야했습니다. –

관련 문제