Contribution to Magento Commerce

Contribution to Magento 2 is getting more and more complex. Your changes need to be backwards-compatible and compliant with all the Magento projects (Commerce and B2B with PageBuilder and MSI installed). It’s also a must to be compliant with Magento Coding Standard.

The guard of all changes is robust Continuous Integration tool that runs Static Tests, Integration Tests and Functional Tests on Magento 2 Open Source, Magento 2 Commerce and B2B with Multi-Source Inventory and PageBuilder installed.

Set of tests executed on Magento contributions

You need to run the same environment locally, to avoid issues with getting your Contribution approved.

Fork repositories

Magento is sharing some of the repositories only with Partners. If your company is one of them – you can get access to these repositories. If you don’t have access, but your company is official partner of Magento – drop a line to engcom@adobe.com and ask to assign you GitHub account.

You cannot work directly in Magento repositories. Contribution to Magento is based on repository forks. To make your own fork, you need to open repository page and click “Fork” in the top-right part of the screen.

Repositories you should fork:

Optional:

Contribution Environment

Though I personally use Warden for local Magento 2 development, these instructions can be applied to any environment.

Clone Magento Open Source code

To begin with – get the development version of Magento 2:

git clone git@github.com:{Github Username}/magento2.git magento2

Please notice that {Github Username} has to be replaced with an account name that you used to fork.

Get your Magento Commerce and B2B

Let’s clone 2 of them, as a good start:

git clone git@github.com:{Github Username}/partners-magento2ee.git magento2/.ee
git clone git@github.com:{Github Username}/partners-magento2b2b.git magento2/.b2b

Please notice that {Github Username} has to be replaced with an account name that you used to fork.

As a result, your directory structure should be:

  • magento2 – Magento Open Source code
    • .ee – Magento Commerce code
    • .b2b – Magento B2B code

If you use PhpStorm, you can already configure these paths to use Version Control System.

Add magento remotes

You can run these commands in magento2/ directory

git remote add magento git@github.com:magento/magento2.git
git -C .ee remote add magento git@github.com:magento/partners-magento2ee.git
git -C .b2b remote add magento git@github.com:magento/partners-magento2b2b.git

That enables you to fetch the latest changes from Magento 2.4-develop branch:

git fetch -a
git merge magento/2.4-develop

git -C .ee fetch -a
git -C .ee merge magento/2.4-develop

git -C .b2b fetch -a
git -C .b2b merge magento/1.2-develop

As a result – your local branch is up-to-date with the latest Magento codebase.

Link modules

Magento Commerce is shipped with a CLI tool that creates symlinks from Commerce’s app/code modules to Open Source’s app/code. The tool is available at dev/tools/build-ee.php, and it needs to be run with PHP.

For example:

php .ee/dev/tools/build-ee.php --ce-source . --ee-source .ee
php .ee/dev/tools/build-ee.php --ce-source . --ee-source .b2b

If you run any type of virtualisation, you need to run this command inside the environment, as the symlinks are created using absolute paths. As a result of above-mentioned commands, you’ll get symbolic links created inside magento2/app/code to Commerce and B2B modules. Verify on your own with ls -al magento2/app/code/Magento

drwxr-xr-x    AdminAnalytics
lrwxr-xr-x    AdminGws -> /var/www/m2.tips/magento2/.ee/app/code/Magento/AdminGws
drwxr-xr-x    AdminNotification
lrwxr-xr-x    AdvancedCatalog -> /var/www/m2.tips/magento2/.ee/app/code/Magento/AdvancedCatalog
lrwxr-xr-x    AdvancedCheckout -> /var/www/m2.tips/magento2/.ee/app/code/Magento/AdvancedCheckout
drwxr-xr-x    AdvancedPricingImportExport
lrwxr-xr-x    AdvancedRule -> /var/www/m2.tips/magento2/.ee/app/code/Magento/AdvancedRule
lrwxr-xr-x    AdvancedSalesRule -> /var/www/m2.tips/magento2/.ee/app/code/Magento/AdvancedSalesRule
drwxr-xr-x    AdvancedSearch
drwxr-xr-x    Amqp
...

The same tool (build-ee.php) may be used for PageBuilder and all the projects that repository structure contains app/code. This means that you cannot use it for Multi-Source Inventory, which uses metadata. In my opinion setting up Magento Multi Source Inventory for contribution is well described in documentation.

Have fun!

The only thing left to be done is… Install Magento. You’re ready to Contribute!

3 Comments

Write a Comment

Your email address will not be published. Required fields are marked *