I've been following this thread but I couldn't get it to work, How do I get my Collection to use a different DB connection?.
I'm trying to load a collection from an external database separate from the main magento database.
config.xml:
<otherdb_setup>
<connection>
<host><![CDATA[127.0.0.1]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[]]></password>
<dbname><![CDATA[otherdb]]></dbname>
<model>mysql4</model>
<initstatements>SET NAMES utf8</initstatements>
<type>pdo_mysql</type>
<active>1</active>
</connection>
</otherdb_setup>
<otherdb_write>
<connection>
<use>otherdb_setup</use>
</connection>
</otherdb_write>
<otherdb_read>
<connection>
<use>otherdb_setup</use>
</connection>
</otherdb_read>
Then on my collection file (class Custom_Module_Model_Mysql4_Mod_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract):
public function _construct()
{
$this->_init('custom_module/mod');
$resource = Mage::getSingleton('core/resource');
$conn = $resource->getConnection('otherdb_read');
$this->setConnection($conn);
}
I'm stuck on this part.