Moving Core Edits to Private Modules

I need some help moving some edits I made to the core files to my own module. I was able to do this easy enough with my frontend edits but I am unsure how to fully move my core file edits.

I edited files in paypal and shipping including the layout under configuration. I had to add some fields to these forms and how they processed the new fields. I remember all my edits but before I make too many to move them back can someone please help me with the appropriate file structure/location.

I am assuming moving the core edits will be as easy as moving the frontend edits but if I am wrong please be kind. I am still learning the structures for magento. Thanks!

Solutions

There are two "levels" of correctness for fixing your core hacks.

The first is to use the local code pool. Whenever Magento instantiates an object (except for controller objects, which are different), it looks for a class file in four different locations.

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

Core files are in the core code pool. You'll want to move your files there. So if you edited

app/code/core/Mage/Core/Model/Url.php

You would want to copy the file to

app/code/local/Mage/Core/Model/Url.php

and then restore the original

app/code/core/Mage/Core/Model/Url.php

That's code pool overrides. The benefit of a code pool override over a core hack is it allows you to keep track of what changes you've made, and your changes won't be lost when you upgrade the system.

True Magento Modules and Class Rewrites

Code pool overrides aren't perfect. When you upgrade Magento, you still need to merge changes to the core files with your own, and this can be tricky if a file's changed extensively.

The best approach to use is a class rewrite. The high level steps involved here are

  • Create a Magento module
  • Identify the "class alias" for your block, model, and helper (such as catalog/product
  • Add configuration to config.xml that tells Magento "When you instantiate a catalog/product object, use my class instead".
  • In your class redefine only the methods you want, and (based on your needs), call the original method with the parent::methodName

The above is more involved, but it will decrease the likelihood of your customizations breaking updated versions of Magento, and by putting your changes in a module, you can distribute it easily to any Magento system. The how/why of creating a class rewrite is beyond the scope of a single Stack Exchange answer, but there's plenty of tutorials out there on how to do it, and the community here is more than willing to help a motivated developer figure it out.

Similar questions

Customer Account - Not saving after backend edits
Whenever we try to make an edit to a customer record (in the backend), it will not allow us to save. The 'Please Wait...' loading image appears in the middle of the screen and stays there to no end. When I refresh and log back in (after timeout) the changes are not there.
Magento 2.3.1 - Cant Save Edits to Product. Nothing Happens
I am on Magento 2.3.1, with php 7.1 When I edit an existing product, and then click save. Nothing happens when I push save. Its like its not registering. I clicked the other save option (Save & Close), (Save & New), and still nothing happens! This is happening on two seperate versions of Magento 2.3.1 Any ideas?
Edits to Category pages not showing
A couple of months ago I ran a special sale on my two stores' sites. I added info to the category page's header *("Prices have been discounted an additional 25% off now through 8-31-20! Discounted price reflected in your shopping cart")*to call attention to the additional discount. Once the sale was over I removed the verbiage, but it sti...
Module that edits existing product names in magento?
Please I am trying to create a module in magento that edits the products' name by concatenating the existing product names with randomly generated numbers. $model = Mage::getModel('catalog/product') ->load(1111) //getting product model $collection = $model->getCollection(); //products collection foreach ($collection as $product) //loop for ge...
How to override magento core model (model class file direct under app/code/core/Mage/Core/Model directory)
I want to override an core model class, but I cannot find the correct way to do it. I have googled a lot, but some of the examples are shown how to override a model which are not located at app/code/core/Mage/Core/Model folder and some of the examples are shown how to override a model which in the sub-dir of Core dir, like app/code/core/Mage/Core/M...
How to enable modules (undo "Disable Modules Output") without admin access
i have just disabled some modules in magento. and i think we have disabled some important modules. what i have done is: system > configuration > advanced > Disable Modules Output i have disables every thing from there .the problem is now i can not access my admin panel. i have disabled some mage or important modules as well. can some one tell me ho...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.