Pages

Wednesday 7 January 2015

Mage_Eav_Model_Entity_Abstract setConnection() must be an instance of Zend_Db_Adapter_Abstract, string given

I got this error while I was installing a third party Magento module. Actually, the module was tested for higher Magento version than 1.4 and I had to install that module on Magento version 1.4.
Cause:
In older Magento versions, setConnection() function of Mage_Eav_Model_Entity_Abstract class expects the parameters only on Zend_Db_Adapter_Abstract type.
Whereas, in newer Magento version, setConnection() function of Mage_Eav_Model_Entity_Abstract class expects the parameters to be either Zend_Db_Adapter_Abstract or string type.
Solution:
Your line of code which resulted in this error might be like the one below:               
$this->setConnection('customer_read', 'customer_write');
You have to change it to:
$resource = Mage::getSingleton('core/resource');
$this->setConnection($resource->getConnection('customer_read'), $resource->getConnection('customer_write'));

No comments:

Post a Comment