3

I want to create an upgrade-safe child theme mypackage/mytheme of the default rwd/default theme.

Magento's RWD dev guide says:

To customize styles for an existing Magento theme, you should edit existing Sass partials.

This sounds as if it was best practice to copy the existing Sass partials to one's own theme to override them and edit them there. The problem is that with each Magento update, one would again need to compare the files and merge the changes manually. I would consider it best practice to always define new Sass partials similarly named as the default ones and make all customisations there. For instance, in order to customise the header, I would do the following:

  1. Create a new file mypackage/mytheme/scss/layout/_custom_header.scss with my modifications to the header CSS.
  2. Edit the file mypackage/mytheme/scss/_core.scss and add the following line at the end:

    @import "layout/custom_header";
    

This would make an upgrade easy as it should normally not be necessary to compare the changed rwd/default Sass partials with the custom ones. So why does Magento / Classy Llama suggests copying the files? Do I overlook some disadvantages of the describes method?

I have read the text directly behind the cited sentence where Magento suggests a similar method. Anyway, they say you should use it "if you are building a highly custom theme". I think it is good to use it for any theme. I do not see any disadvantage of this method

3

Great question, Simon. First, you need to consider fact that Magento 2 is planned to be released later this year. So there will likely be few releases of Magento 1.x that will make significant changes to the Sass partials in the theme. With this being the case, the risks associated with editing the "core" Sass partials is small.

That being said, you are right to question the merits of editing the existing Sass partials, rather than creating new partials. From an idealistic perspective, you would want to avoid editing any core Sass partials in order to make your custom theme more upgrade-friendly. However from my experience, creating all Sass in new partials will increase your development time (if but slightly).

When considering which approach to take, a developer should weigh the importance of upgradability vs efficiency and pick the approach that is best for their project.

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.