2010-03-10 2 views
2

Magento는 다른 당사자 시스템과 통합하기 위해 기존 데이터베이스 테이블에 데이터를 읽고 쓸 필요가 있습니다. 테이블의 이름을 바꿀 수 없습니다. 아래 에서처럼 magento가 모델 구성의 table 태그에이를 지정하면 접두사가 추가됩니다. 접두사를 어떻게 든 무시할 수 있습니까?Magento 모델에서 테이블 이름과 접미사를 재정의하는 방법은 무엇입니까?

<models> 
     <arithmetic> 
      <class>Mcmr_Arithmetic_Model</class> 
      <resourceModel>arithmetic_mysql4</resourceModel> 
     </arithmetic> 
     <arithmetic_mysql4> 
      <class>Mcmr_Arithmetic_Model_Mysql4</class> 
      <entities> 
       <arithmetic> 
        <table>newslettersignups</table> 
       </arithmetic> 
      </entities> 
     </arithmetic_mysql4> 
    </models> 

답변

0

쉬운 방법은 없습니다.

<models> 
    <arithmetic> 
     <class>Mcmr_Arithmetic_Model</class> 
     <resourceModel>arithmetic_mysql4</resourceModel> 
    </arithmetic> 
    <arithmetic_mysql4> 
     <class>Mcmr_Arithmetic_Model_Mysql4</class> 
     <entities> 
      <arithmetic> 
       <ignore_prefix>1</ignore_prefix> 
       <table>newslettersignups</table> 
      </arithmetic> 
     </entities> 
    </arithmetic_mysql4> 
</models> 

그런 다음 당신이 엔티티에 대한 추가 설정 속성 "ignore_prefix"를 고려하기 위해 Mage_Core_Model_Resource 클래스의 getTableName 방법을 무시할 수 :

가장 좋은 방법은 구성 파일을 확장하는 것입니다.

if ($mappedTableName) { 
    $tableName = $mappedTableName; 
} else { 
    if($entityConfig->ignore_prefix) 
     $tablePrefix = ''; 
    else 
     $tablePrefix = (string)Mage::getConfig()->getTablePrefix(); 
    $tableName = $tablePrefix . $tableName; 
} 
관련 문제