0

I have extended classes from core in Magento before, but am uncertain how to extend this class:

Varien_Db_Adapter_Pdo_Mysql
//located in lib/Varien/Db/Adappter/Pdo/Mysql.php

How would I do this?

1

If by extending you mean override them, then the answer is: you can't. There is no way to do a rewrite in your own extension for a lib class. Well, there is one way to do that. You can make a copy of the file in the app/code folder.

So for this file: lib/Varien/Db/Adappter/Pdo/Mysql.php, you could make a copy of that file in app/code/local/Varien/Db/Adappter/Pdo/Mysql.php to override the class.

0

For this problem, I create a class in lib/Exemple/Db/Adapter/Pdo/Mysql.php with extend Magento_Db_Adapter_Pdo_Mysql

class Exemple_Db_Adapter_Pdo_Mysql extends Magento_Db_Adapter_Pdo_Mysql

And I changed the adapter in config file

app/etc/config.xml

<resource>
    <connection>
        <types>
            <pdo_mysql>
                <adapter>Exemple_Db_Adapter_Pdo_Mysql</adapter>
                <class>Mage_Core_Model_Resource_Type_Db_Pdo_Mysql</class>
                <compatibleMode>1</compatibleMode>
             </pdo_mysql>
        </types>        
    </connection>        
</resource>

Because you have in lib

lib/Varien/Db/Adapter/Pdo/Mysql.php

class Varien_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql implements Varien_Db_Adapter_Interface

and in lib/Magento/Db/Adapter/Pdo/Mysql.php

class Magento_Db_Adapter_Pdo_Mysql extends Varien_Db_Adapter_Pdo_Mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.