2012-04-17 3 views
3

Magento에 문제가 있습니다. 나는 magento.one 데이터베이스와 두 데이터베이스를 연결하고 싶습니다 메인 데이터베이스와 다른 가게 될 것입니다. 나는 이 거짓 도와주세요 내 local.xml입니다 ..... it.By 내 연결이 파일 응용 프로그램은/etc/local.xml에이 시간을 어떻게 해야할지 다음과 해달라고 [mysql4]> 두 데이터베이스에 magento 연결

+0

http://blog.decryptweb.com/connect-database-magento/이 링크를 사용해보십시오 – sulabh

답변

2

내가 구현 한보다 우아한 해결책이 있지만 내 방법이 효과적 일 수 있습니다. osCommerce 가져 오기/내보내기 모듈에서이 작업을 수행했습니다.


/httpdocs/app/etc/config.xml이 당신에게 당신의 모델 내에서 oscommercedb를 호출 할 수있는 기능을 제공

 <!-- osCommerce db/read/write --> 
     <oscommercedb> 
      <connection> 
       <host>localhost</host> 
       <username>root</username> 
       <password>pass</password> 
       <dbname>oscommerce_database_name</dbname> 
       <model>mysql4</model> 
       <initstatements>SET NAMES utf8</initstatements> 
       <type>pdo_mysql</type> 
       <active>1</active> 
      </connection> 
     </oscommercedb> 
     <oscommercedb_write> 
      <connection> 
       <use>oscommercedb</use> 
      </connection> 
     </oscommercedb_write> 
     <oscommercedb_read> 
      <connection> 
       <use>oscommercedb</use> 
      </connection> 
     </oscommercedb_read> 
     <!-- end osCommerce db --> 

. 위의 코드는 <resources> 블록 안에 있습니다.

이제 모델을 살펴 보겠습니다. /httpdocs/app/code/local/Company/Extension/Model/OsCustomers.php

class Company_Extension_Model_OsCustomers extends Mage_Core_Model_Abstract 
{ 

protected $_name = 'customers'; // name of the table 

/** 
* Returns rowset of tables for customers 
* 
* @return Zend_Db_Table_Rowset 
*/ 
public function getAllOscommerceCustomers() 
{ 
    $read = Mage::getSingleton('core/resource')->getConnection('oscommercedb'); 

    $stmt = $read->select(); 

    $stmt->from(array('c' => 'customers')) 
     ->join(array('a' => 'address_book'), 'a.address_book_id = c.customers_default_address_id') 
     ->joinLeft('zones', 'zones.zone_id = a.entry_zone_id') 
     ->join('countries','a.entry_country_id = countries.countries_id', array('countries_iso_code_2')); 

    return $read->fetchAll($stmt); 
} 

특정 문제가 발생하는 경우


은 알려주세요.

+0

도움을 주셔서 대단히 감사합니다. 코드를 사용하여 매우 쉽게 할 수있었습니다. –

+0

감사합니다. 좋은 일을 계속 지키라. –