The correct way to modify core code - need clarification
-
11-12-2019 - |
Question
I'm preparing my installation of 1.8 to upgrade to the latest. Over the past year I've had a few different developers assist me and even though I ask them not to modify core code, some do anyway.
I've done a search for any files modified past the installation date and have come across a few that need to be preserved.
Question
If file /code/core/Mage/CatalogSearch/Block/Result.php has been modified, my understanding is that to protect this from the upgrade I need to move it /code/local/Mage/CatalogSearch/Block/Result.php ?
Is moving modified core code to the /app/code/local the correct way to protect modified files from upgrades?
Solution
Yes, magento will take the class from the local folder. But it could lead to a wrong magento behavior, because the new version may assume the class has a new methods. And the old version does not have them.
I recommend you run diff command to see the changes an move them into a separate extension class, that extends the core one. This allows to use new features an do not lost the modifications.