5

I have a couple of php files in magento lib that I need to rewrite in order to change the functionality. I searched about this but all the solutions I found did not work. Does anyone know how to properly rewrite these files?

  • Welcome to Magento SE! I tried to answer the question but it would have helped if you specified the Magento version because there are major differences between 1.x and 2.x. Also, it helps if you wrote which solutions you tried, so we do not waste our time with giving you exactly those again ;) – Fabian Schmengler Mar 9 '17 at 21:13
4

You can copy the file from lib to app/code/local, for example, app/code/local/Varien/Object.php. The Magento autoloader looks for class files in these directories (in that order):

  • app/code/local
  • app/code/community
  • app/code/core
  • lib

Unfortunately there is no cleaner way, like with class rewrites to do so (see also: https://stackoverflow.com/questions/14860858/magento-rewrite-lib-file/14861227#14861227)

For Magento2 you can replace any classes using preferences in di.xml. Read more: http://devdocs.magento.com/guides/v2.1/extension-dev-guide/build/di-xml-file.html

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.