Introduction

Magento 2 is a modular PHP commerce platform; how Open Source and Adobe Commerce differ, and what this course builds.

Syntaxmagento/product-community-edition (Open Source) | magento/product-enterprise-edition (Adobe Commerce)

Magento 2 is a commerce platform written in PHP and installed with Composer. You do not edit it, you extend it. The platform arrives as Composer packages under vendor/, and your work lives in your own modules under app/code. A module is a directory of PHP and XML that registers itself with the application and can be switched on or off.

Two editions

Magento Open Source is free and self-hosted. Adobe Commerce is licensed and adds B2B, content staging and preview, customer segments and Adobe's hosted services on top of the same core. The older names survive in the package names and in everyday speech: Open Source is community-edition, shortened to CE; Adobe Commerce is enterprise-edition, shortened to EE. CE and Open Source are the same thing, and so are EE and Adobe Commerce.

This course documents Magento 2.4.9 on PHP 8.4. Everything here runs on Open Source. Where a feature needs Adobe Commerce, the lesson says so instead of teaching something you cannot install.

Where the course ends

By the last stage you will have a module with its own admin configuration, its own table filled by a data patch, a storefront route with a template, REST and GraphQL endpoints, and a deployment that survives an upgrade.

What trips people up

Most Magento answers online were written for 2.2 or 2.3 and use install and upgrade scripts that no longer run. Check the version of anything you copy. And a saved file changes nothing on its own: a command applies it.

Example

Example · php
<?php
// app/code/Vendor/Diagnostics/Service/PlatformInfo.php

declare(strict_types=1);

namespace Vendor\Diagnostics\Service;

use Magento\Framework\App\ProductMetadataInterface;

class PlatformInfo
{
    private ProductMetadataInterface $productMetadata;

    public function __construct(ProductMetadataInterface $productMetadata)
    {
        $this->productMetadata = $productMetadata;
    }

    public function describe(): string
    {
        return sprintf(
            '%s %s (%s)',
            $this->productMetadata->getName(),
            $this->productMetadata->getVersion(),
            $this->productMetadata->getEdition()
        );
    }
}

// Output of describe() on Magento Open Source 2.4.9:
// Magento 2.4.9 (Community)
//
// Output of the same call on Adobe Commerce 2.4.9:
// Magento 2.4.9 (Enterprise)

When to use it

  • Deciding whether a requested feature ships with Open Source or needs an Adobe Commerce licence.
  • Checking whether an answer found online applies to 2.4.9 before copying it.
  • Telling a client which edition and version their existing store runs.

More examples

The two metapackages

The edition is decided by one package name. Reach for this when you are setting up a project and need to know which of the two you are entitled to install: the Adobe Commerce package is refused by the repository unless the access keys belong to a licensed account.

Example · bash
# Magento Open Source
composer create-project --repository-url=https://repo.magento.com/ \
    magento/project-community-edition:2.4.9 /var/www/magento

# Adobe Commerce - the same command, a different package, and the
# access keys must belong to an account with a licence
composer create-project --repository-url=https://repo.magento.com/ \
    magento/project-enterprise-edition:2.4.9 /var/www/magento

Your code against platform code

Reading core code under vendor/ is normal and necessary - it is the most reliable documentation there is. Editing it is not: the next composer update or security patch overwrites the file, and nothing records that the change existed.

Example · bash
# yours: write, commit, deploy
app/code/Vendor/Catalogue/

# the platform: read it constantly, edit it never
vendor/magento/module-catalog/

# where a core class ends up after a plugin or a factory is generated
generated/code/Magento/Catalog/Model/Product/Interceptor.php

Discussion

  • Be the first to comment on this lesson.