Magento Forum

   
Page 1 of 2
Changing the core code - how to prevent it from being overwritten with updates? 
 
lisali
Enthusiast
 
Avatar
Total Posts:  888
Joined:  2008-04-28
London, UK
 

Hello,

As I am changing some of the core code, is there a way to prevent it from being overwritten with updates through Magento connect?

What would be the best way to preserve those files?

Many thanks!
Lisa

 
Magento Community Magento Community
Magento Community
Magento Community
 
laurent
Member
 
Total Posts:  75
Joined:  2007-08-31
Paris, France
 

The simplest way I know is to put your modified files in app/code/local/Mage instead of app/code/core/Mage.
For exemple, if you want to change code in Breadcrumbs.php, just copy the file from app/code/core/Mage/Block/ to app/code/local/Mage/Block/ and the new local file will be automaticaly read instead of the core one. Like that you can be sure your code won’t be overwritten by Magento updates.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Hi Laurent, This is The Great Tips of the week!  smile

Thank you so much! 

Lisali, thanks for asking this question as I was thinking the same thing yesterday.

 
Magento Community Magento Community
Magento Community
Magento Community
 
oxygen
Member
 
Total Posts:  69
Joined:  2008-06-09
 

Thanks for the tips.

What about changes in files in other folders example: /app/design/frontend/default/default/template/ ?

Where shall we put the modified files so that they will not be overwritten during upgrade?

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gui
Guru
 
Avatar
Total Posts:  588
Joined:  2008-03-09
 

I think the best way to do that is simply copy the modified default template and placing the files in new folders:
/app/design/frontend/MyNewDesign/MyNewDesign/template/

See the Wiki and knowledge base what steps other steps are necessary to run the new template.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

I was reading the Designer’s Guide right now for the 4th time as I was creating my Interface (thanks to Moshe’s suggestion) and wanting to make sure I fully understand the concept of Interface.

For the first Magento site, I used my custom code (phtml files and css) as default theme because I didn’t want to keep the original default theme (that is of no use to the site) and use my design as a custom theme. The major concern I have with using default theme for my custom theme is that, when I upgrade Magento, everything in the default folder get replaced, which is fine for now as I make a backup before running the upgrade.

The whole purpose of creating my Interface is because I don’t want to keep magento’s default interface (the default theme) as I have no use of it and I don’t want it taking up server space, and I don’t want it to shows up at all when an error occurs. According to Designer’s Guide: “ your store can only handle loading the theme called ‘default’ and one additional theme of your choice to your store”. Fine with me with just one additional theme for now, but I think I need clarification on ‘loading the theme called ‘default’ and how the upgrade works. And I think the way Magento does the Upgrade can be improved or change a bit.

As mentioned, the upgrade overwrites the default theme. What will it do when I create my Interface and there is no ‘frontend/default/default’ anymore? Instead, the directory shows only ‘frontend/my_interface/default.  When I do an upgrade via Magento Connect, I presume Magento likely to load the original default theme to skin and app folders right ?  Though my Interface will be intact, it is still not ideal for stores that don’t need a default theme as I will have to delete them again

I am thinking, perhaps a better approach for Magento Upgrade via Magento Connect is to have option whether a user wants to overwrites these two directories:
app/design/frontend/default/default
skin/frontend/default/default/

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  888
Joined:  2008-04-28
London, UK
 

Many thanks laurent for explaining this, much appreciated!

So basically - one just has to recreate the directory structure and place modified files in app/code/local, and if there’s anything there, it will be read from there instead of from app/code/core?

As someone else asked, could you explain how to do the same for theme/skin files for the front-end - I have done as advised in the Magento designer guide, and copied the default theme and renamed the directories, and enetered the new skin name in the admin, but it’s not working...it seems to be pulling some CSS files from the new theme but the rest from the original one?

Many thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
laurent
Member
 
Total Posts:  75
Joined:  2007-08-31
Paris, France
 
lisali -

So basically - one just has to recreate the directory structure and place modified files in app/code/local, and if there’s anything there, it will be read from there instead of from app/code/core?

Exactly.

As someone else asked, could you explain how to do the same for theme/skin files for the front-end - I have done as advised in the Magento designer guide, and copied the default theme and renamed the directories, and enetered the new skin name in the admin, but it’s not working...it seems to be pulling some CSS files from the new theme but the rest from the original one?

It can be a cache problem. Did you disable cache in admin? You could also remove the content of var/cache.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  888
Joined:  2008-04-28
London, UK
 

Hi Laurent - have completely disabled cache, but will try deleting var/cache to see if that works.

So there’s no need o change anything in the index.php or I believe I read in another thread, some xml file maybe?

Thank you so much!

Lisa

 
Magento Community Magento Community
Magento Community
Magento Community
 
ralphie
Member
 
Total Posts:  59
Joined:  2007-12-20
London
 

hi lisa

this is the correct behavior. magento loads all the defined files, if you are talking about js and css files they would be defined in:

app/design/frontendyour_interface/your_theme/layout/page.xml

magento will first search for the defined files in your theme and if it can not find it it would fall back to the default. bottom line if you dont want magento files loaded you have to not load them (remove them out of the xml, or just comment them out there).

cheers,

ralph

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  888
Joined:  2008-04-28
London, UK
 

Hey,

Many thanks everybody for your replies, they have been of huge help!

I have made it work now - I had copied the files to the wrong directory, so that’s why they were not called.

In system>>config>>design, under Themes, you just enter the new theme in the Default box. Works like a charm!

Man thanks again!
Lisa

 
Magento Community Magento Community
Magento Community
Magento Community
 
oxygen
Member
 
Total Posts:  69
Joined:  2008-06-09
 

hi everyone,

I need help as I am a bit lost here.

I changed some files in /app/design/frontend/default/default/template/…

As suggested I created new folders for the new files, they are now in /app/design/frontend/default/NEW/template/…

Also I copy the boxes.css to the new folder as well under skin/frontend/default/NEW/css/.

Then I go to System->Config->Design->Themes, set Templates, Skin, and Layout to NEW. Is this correct?

I notice the changes only take effect in the subsequent pages. The home page is not affected by the changes at all.

What could be the problem? Did I miss anything or did I miss out any files?

Thank you very much.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Generally speaking you usually only have to change the Default box to your new theme, ‘NEW’, and it should pull all the data.  Now the other thing to keep in mind is that if your theme is missing anything it will fallback to the default theme to find it.  If you haven’t turned off the cache make sure to do so or else it won’t be accurate all the time.  I can’t remember what the homepage is pulling, I think 3Columns.phtml which you could check the layout settings in page.xml under layout.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
oxygen
Member
 
Total Posts:  69
Joined:  2008-06-09
 

hi,
Thanks for your reply.
I set the Default field under System->Config->Design->Themes to NEW.
The homepage does not change. Do I need to copy the 3columns.phtml to my new theme directory NEW/page?

Also, I copy boxes.css to my skin/frontend/default/NEW/css directory.
The boxes.css is in effect in subsequent pages (as seen from firebug), however, somethings are missing, for example, the RSS feed icon is missing.

The homepage doesn’t change, the RSS icon is still there.

And in the homepage, it is still pulling from the default/default/css/boxes.css.
What could be the problem?

By the way, my Current package name is set to default.

Really appreciate if you could help.

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

I would try copying the 3Colums.phtml over, what I did for my theme was copy the entire default theme directory over, that way everything would be read from my new theme directory and I could control changes a bit better.  I would give that a shot.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
oxygen
Member
 
Total Posts:  69
Joined:  2008-06-09
 

Thank you.

I copied the whole directory of images to my new theme directory, and the icon RSS shows up.
So I suppose I have to do the same thing for the rest of the templates.

Thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2