Showing results for 
Search instead for 
Did you mean: 

Editing the Magento Core For Fun and Profit

M1 Certified

One of the first things a new Magento developer learns is “never edit the core”. Both Magento 1 and Magento 2 are designed to be easily upgradable, and a key component of that ability to upgrade is the fact that there are a set of core files living under the Magento namespace that should never be edited. This is such common knowledge (and a frequent complaint when you inherit a project from another developer) that it’s become a meme, first as an image of Magento Evangelist Ben Marks demanding to know “Did you just edit the core?” and later as stickers and t-shirts featuring that image.


However, thanks to the efforts of Magento’s Community Engineering team, editing the core is not just allowed, it’s encouraged! Specifically, Magento now has a process through which anyone can submit a pull request containing a bug fix, improvement or new feature to the Magento core, so that all Magento users can benefit from it. This type of core edit not only preserves the upgradability of the Magento system, it allows Magento to operate as a true open source project, with contributors from all over the world.


Let’s take a look at the value of contributing to the Magento core, how to go about contributing, who can contribute and some recent contributions I’ve been involved with here at Creatuity.


Why Should I Contribute?

If you’re already an open source advocate, then you already understand the value of participating in an open source project by contributing. For those that are new to open source contributions, though, there are many benefits to contributing to any open source project, and there’s some strong reasons to contribute specifically to Magento.


Magento is a complex system consisting of thousands of files with a very strong set of architectural patterns. Resolving an open issue and submitting a pull request with the fix will give you a deep education and understanding of how different pieces within the Magento architecture interact more than any other task you complete in Magento ever will.


Pull requests you submit to Magento are reviewed by community volunteers as well as core Magento developers and architects. This allows you to learn from some of the brightest minds that are most familiar with the Magento system.


From a completely capitalist viewpoint, contributing to the core Magento product can be an excellent way to further your own career. Each year, merchants running on the Magento platform generate over $100 billion in revenue. Service providers, developers, hosting companies and other similar enterprises generate over $4 billion in revenue each year providing services to those merchants. There are tens of thousands of developers competing for the attention of those merchants and agencies, but less than 500 of those developers have contributed to the Magento core. Nothing stands out on a resume or project proposal like the fact that you have written a piece of the Magento core code.


On the opposite end of the spectrum, contributing to the Magento core is a great way to give back. Many of us have jobs, friends and opportunities we never would have had if Magento didn’t exist. At a minimum, if you’ve been working with the Magento platform for more than a month or two, chances are you’ve used at least one open source tool or contribution from another developer. Contributing a fix or new feature to the Magento core is a great way to pay it forward and repay that kindness with a contribution of your own.


Finally, if you have a chance to attend a Magento Contribution Day, often held in conjunction with a Magento-focused conference, contributing can be quite a bit of fun. There’s nothing quite like being in a room full of developers who understand the Magento platform and working on resolving a nagging bug or issue in Magento together.


How Do I Contribute?

Now that you’re excited to contribute to the Magento, hopefully for both fun and profit, how do you contribute? Contributions take on quite a few different forms, but for now let’s assume you’re thinking of writing some code and submitting a pull request to the Magento core. These pull requests are all processed and overseen by the Magento Community Engineering team, a group of Magento Inc. employees that focus on three major initiatives:


  1. Processing pull requests submitted to the community on the Magento 2 GitHub repository and encouraging those contributions and assisting those contributors.
  2. Working with a group of community contributors on a major new feature for Magento 2 - multi-source inventory. This is a massive co-development effort between Magento Inc and a number of community contributors.
  3. Managing the Magento Partner Contributions Program, a method by which Magento partner agencies are able to submit pull requests to Magento.


If after reading this article you’re still not sure how to contribute or what to contribute, the official [Magento Community Engineering Slack channel] is a great place to chat with the Community Engineering team. You can request access to that Slack group by emailing engcom [at] magento [dot] com.


Magento labels issues on the Magento 2 GitHub repository with the label ‘up for grabs’ when the issue seems like one that would be good for a community member to contribute, but community members are always welcome to fix any issue they’d like. Magento also organizes events such as this year’s “Squashtoberfest” where they will tag a specific set of issues on the Magento 2 GitHub repository as targets for the event and then give prizes and special recognition to community members for resolving those issues with a pull request by a specific deadline. These events help Magento bundle fixes and contributions into specific upcoming releases.


Finally, Magento also encourages their partners to submit through a Partner Community Engineering initiative where Magento solution partners are rewarded when their employees submit pull requests.


Once you’ve identified the specific contribution you want to make, Magento has a set of guidelines on how to submit your contribution, online in the [Magento DevDocs documentation]. These guidelines are similar to working on any other open source project you may have interacted with on GitHub, and primarily consist of:


  1. Fork the Magento 2 GitHub repository, complete your work and submit a pull request.
  2. Once your pull request is submitted, it will go through automated and manual reviews. If additional work or clarification is required, respond within two weeks or the pull request may be closed to keep the Magento 2 repository manageable.
  3. Pull requests that introduce new functionality should also include a corresponding pull request to the Magento DevDocs documentation as well as test coverage to allow for the automated testing of the new functionality.
  4. All contributors must electronically sign a contributor license agreement, outlining your ownership of the code that you’ve contributed and granting Magento the right to use that code.


Anyone Can Contribute

Now that you understand how to contribute, you might be thinking you don’t have the time or maybe aren’t sure if your Magento 2 experience is deep enough to allow you to contribute. It’s important to realize - everyone can contribute! Contributions are much more than just pull requests. While pull requests for bug fixes and new features are wonderful, there are many ways to contribute to the Magento 2 project without writing a single line of code.


If you’re interested in testing, QA and documenting issues, there’s always issues on the Magento 2 GitHub repository that need further details. By scanning the list of open issues, you can look at the labels and easily see if there are issues that the Magento team has been able to reproduce as they will be tagged with labels such as ‘Reproduced on 2.2.x’. You’ll see other issues marked with the label ’needs update’ - these are issues where the original reporter may not have provided enough information or clear steps to reproduce this issue. Oftentimes a fresh set of eyes on the original bug report can discern what the original reporter was referring to and can provide clarification that allows the issue to be reproduced so that it can be resolved.


Opening issues can be a helpful way of contributing as well. When you’re working with any software package on a regular basis it’s common for there to be minor issues that you always work around or ignore. By taking the time to contribute a report documenting the issue or a potential enhancement to Magento, you pave the way for those minor issues to be resolved, improving not just your experience but the experience of every developer working with the Magento platform. Taking the time to write a good, easy to reproduce issue is a great way to contribute to the Magento project.


Finally, the Magento developer documentation team has led the way in embracing an open source ethos. Before the Magento 2 codebase was available on GitHub, the Magento 2 Developer Documentation, “DevDocs”, was on GitHub and accepting pull requests. So, if you enjoy technical writing, contribute to DevDocs! The DevDocs GitHub repository has a list of open issues where developers have listed areas that the documentation may be incorrect or incomplete, so reviewing those issues and then submitting a pull request to DevDocs with updated documentation is another great way to contribute to the Magento project without writing a single line of code. Also, thanks to the fact that the DevDocs accept pull requests, if you ever find a mistake in the documentation you can submit a pull request on the spot to correct it and ensure other developers aren’t tripped up by that error.


Our Recent Contributions

I’ve had the pleasure of being involved in several recent contributions to the Magento 2 core, each of which was an interesting experience that allowed me to grow my skills as a developer. The biggest contribution I have been involved in was when our team at Creatuity built a new feature for Magento 2 - one touch ordering. This feature enhances Magento by allowing customers who have a credit card saved on their account to order a product with a single click on the product page, similar to the one click button on product pages. While designing this feature to determine if it was feasible for us to build it in Magento 2, I learned quite a bit about how the core Magento support for the Braintree credit card processor worked and I was excited to realize that the existing classes and libraries in Magento meant that adding this feature was primarily an effort in connecting existing code in new and different ways.


After completing this new feature, the Creatuity team submitted it through the Partner Community Engineering program, allowing our development team to receive feedback from developers, architects and UX experts at Magento about what we did well and what we could improve. Not only did this result in a better, more polished one touch ordering system in Magento, it allowed us to further develop our skills and hear from viewpoints we might otherwise not encounter. Already this feature, which is scheduled to be released in Magento 2.2.2, has been discussed by Internet Retailer and other industry publications, allowing our work to receive more attention than it otherwise would’ve if we hadn’t contributed it to the core.


I also had an opportunity to join the Magento Contribution Day held before Meet Magento New York 2017, where we worked on issues from the Squashtoberfest event. Reading through the list of issues with the group at that event helped us all get a better sense for the type of issues that are being opened on the Magento 2 repository each day and how challenging it can be to understand, reproduce and resolve an issue that was reported by someone else. I worked on two different issues, both of which resulted in a pull request back to the core. Interestingly enough, one of those pull requests wasn’t accepted (pull request # 11501), and it was primarily because my pull request and the resulting discussion led the core Magento team to realize that due to a particular architectural decision made in the Magento platform, the cost and potential risk of resolving a minor issue outweighed requiring the few developers impacted by this issue to apply a simple workaround. This resulted in the original issue being closed and the developer that reported it provided with a workaround. While it was disappointing to spend time developing a solution that ultimately wasn’t used, it was a great experience to learn much more about how the SOAP and REST APIs function under the hood in Magento.


The other Squashtoberfest pull request I wrote (pull request # 11499) involved resolving some unexpected behavior with Magento’s integration tests. Resolving this issue required several hours of research to understand how Magento prepared the test database for running the integration tests, giving me a much better understanding of how Magento’s automated testing suite works. After this research, I realized that resolving this unexpected behavior required only a few lines of code to be changed. That pull request has been accepted and will be released in an upcoming update to Magento 2.2, benefiting everyone who uses automated testing with Magento 2.


Through these efforts, contributing to Magento has been a great experience for both myself and for Creatuity, and I encourage you to get involved and try it as well.


Go Forth and Edit the Core!

I hope that you are convinced of the value of contributing to the Magento project. By moving to a fork-and-pull, open contribution model on GitHub for Magento 2, the Magento core team has opened up the development process to more contributions than were ever possible in the past. I hope that as a community we all continue to embrace this spirit of openness and each find a way to make some type of open source contribution back to Magento. So, go forth and edit the core!


This article was originally published in php[architect] magazine: Modern Magento – November 2017.