magento2
Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
Top Related Projects
A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.
PrestaShop is the universal open-source software platform to build your e-commerce solution.
A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
Quick Overview
Magento 2 is an open-source e-commerce platform written in PHP. It provides online merchants with a flexible shopping cart system, as well as control over the look, content, and functionality of their online store. Magento 2 offers powerful marketing, search engine optimization, and catalog-management tools.
Pros
- Highly customizable and scalable for businesses of all sizes
- Large community and ecosystem with numerous extensions and themes
- Advanced features for multi-store management and B2B commerce
- Built-in SEO optimization tools and mobile-responsive design
Cons
- Steep learning curve for developers new to the platform
- Can be resource-intensive, requiring robust hosting solutions
- Upgrades can be complex and time-consuming
- Some features may require additional paid extensions
Code Examples
- Creating a simple module:
<?php
namespace Vendor\Module\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
// Installation logic here
}
}
- Adding a custom product attribute:
<?php
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'custom_attribute',
[
'type' => 'varchar',
'label' => 'Custom Attribute',
'input' => 'text',
'required' => false,
'visible_on_front' => true,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
]
);
- Creating a custom controller:
<?php
namespace Vendor\Module\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
protected $resultPageFactory;
public function __construct(Context $context, PageFactory $resultPageFactory)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
return $this->resultPageFactory->create();
}
}
Getting Started
- Install Magento 2 using Composer:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation-directory-name>
- Set up file permissions:
cd <installation-directory-name>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .
chmod u+x bin/magento
- Install Magento via CLI:
bin/magento setup:install --base-url=http://localhost/magento2 --db-host=localhost --db-name=magento --db-user=magento --db-password=magento --admin-firstname=Admin --admin-lastname=User --admin-email=admin@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
- Access your Magento 2 installation through the browser and complete the setup wizard.
Competitor Comparisons
A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.
Pros of OpenCart
- Simpler and more lightweight, making it easier to set up and manage for small to medium-sized businesses
- Lower learning curve for developers and store owners
- Faster performance due to its lightweight nature
Cons of OpenCart
- Less robust feature set and customization options compared to Magento 2
- Smaller ecosystem of extensions and themes
- Limited scalability for large, complex e-commerce operations
Code Comparison
Magento 2 (PHP):
<?php
namespace Magento\Catalog\Model;
class Product extends \Magento\Catalog\Model\AbstractModel
{
// Complex product model implementation
}
OpenCart (PHP):
<?php
class ModelCatalogProduct extends Model {
public function getProduct($product_id) {
// Simpler product retrieval implementation
}
}
Magento 2 uses a more complex, object-oriented approach with namespaces and inheritance, while OpenCart employs a simpler, more straightforward coding style. This reflects the overall complexity and flexibility differences between the two platforms.
Magento 2 is better suited for large-scale, complex e-commerce projects with extensive customization needs, while OpenCart is more appropriate for smaller businesses looking for a simpler, easier-to-manage solution.
PrestaShop is the universal open-source software platform to build your e-commerce solution.
Pros of PrestaShop
- Lighter and faster performance, especially for smaller stores
- More user-friendly admin interface, easier for non-technical users
- Free and open-source with a larger community of developers
Cons of PrestaShop
- Less scalable for large, complex e-commerce operations
- Fewer built-in features and extensions compared to Magento 2
- Limited multi-store functionality
Code Comparison
PrestaShop (PHP):
class ProductController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'product';
$this->className = 'Product';
parent::__construct();
}
}
Magento 2 (PHP):
namespace Magento\Catalog\Controller\Adminhtml\Product;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultFactory;
class Index extends Action
{
public function execute()
{
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
return $resultPage;
}
}
Both PrestaShop and Magento 2 use PHP for their core functionality, but their architectures and coding styles differ. PrestaShop tends to have a simpler structure, while Magento 2 follows a more complex, modular approach. This reflects their respective focuses on smaller vs. larger e-commerce operations.
A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
Pros of WooCommerce
- Easier to set up and use, especially for beginners
- More lightweight and faster performance out of the box
- Seamless integration with WordPress ecosystem
Cons of WooCommerce
- Less scalable for large, complex e-commerce sites
- Fewer built-in features for advanced e-commerce functionality
- Limited multi-store capabilities
Code Comparison
WooCommerce (PHP):
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
Magento 2 (PHP):
<block class="Magento\Catalog\Block\Product\View" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" template="Magento_Catalog::product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getDescription</argument>
<argument name="at_code" xsi:type="string">description</argument>
<argument name="css_class" xsi:type="string">description</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Details</argument>
</arguments>
</block>
</block>
The code comparison shows that WooCommerce uses WordPress-style action hooks for content output, while Magento 2 uses a more complex XML-based layout system for defining block structures and templates.
Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
Pros of Shopware
- Lighter weight and faster performance out of the box
- More intuitive admin interface for non-technical users
- Easier setup and configuration process
Cons of Shopware
- Smaller ecosystem and fewer extensions available
- Less flexibility for complex, large-scale enterprise implementations
- More limited multi-store and multi-language capabilities
Code Comparison
Shopware (PHP):
class ProductRepository extends EntityRepository
{
public function getProductsWithCategory(int $categoryId): array
{
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('categoryTree', $categoryId));
return $this->search($criteria, Context::createDefaultContext())->getEntities();
}
}
Magento 2 (PHP):
class ProductRepository implements ProductRepositoryInterface
{
public function getList(SearchCriteriaInterface $searchCriteria)
{
$collection = $this->collectionFactory->create();
$this->extensionAttributesJoinProcessor->process($collection);
$this->collectionProcessor->process($searchCriteria, $collection);
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($searchCriteria);
$searchResults->setItems($collection->getItems());
$searchResults->setTotalCount($collection->getSize());
return $searchResults;
}
}
The code comparison shows that Shopware's approach is more straightforward and concise, while Magento 2's implementation offers more extensibility and complexity to handle various scenarios.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Magento Open Source
Welcome to the Magento Open Source project! Magento Open Source software delivers basic eCommerce capabilities to build a unique online store from the ground up.
However, for those who need a full-featured eCommerce solution, we recommend Adobe Commerce, which includes our optimized cloud architecture and hosting as well as AI-powered merchandising and analytics.
Get started
Get help
Contribute
Our Community is large and diverse, and our project is enormous. As a contributor, you have countless opportunities to impact product development and delivery by introducing new features or improving existing ones, enhancing test coverage, updating documentation for developers and end-users, catching and fixing code bugs, suggesting points for optimization, and sharing your great ideas.
- Contribute to the code
- Report an issue
- Improve the developer documentation
- Improve the end-user documentation
- Shape the future of Magento Open Source
Maintainers
We encourage experts from the Community to help us with GitHub routines such as accepting, merging, or rejecting pull requests and reviewing issues. Adobe has granted the Community Maintainers permission to accept, merge, and reject pull requests, as well as review issues. Thanks to invaluable input from the Community Maintainers team, we can significantly improve contribution quality and accelerate the time to deliver your updates to production.
Leaders
Adobe highly appreciates contributions that help us to improve the code, clarify the documentation, and increase test coverage. Check out our Community leaders, superstars, and superheroes on the leaderboard.
Labeling
We use labels in the GitHub issues and pull requests to help the participants retrieve additional information such as progress, component assignments, or release lines.
Security
Security is one of the highest priorities at Adobe. To learn more about reporting security concerns, visit the Adobe Bug Bounty Program.
Stay up-to-date on the latest security news and patches by signing up for Security Alert Notifications.
Licensing
Each Magento source file included in this distribution is licensed under OSL 3.0 or the terms and conditions of the applicable ordering document between Licensee/Customer and Adobe (or Magento).
Open Software License (OSL 3.0) â Please see LICENSE.txt for the full text of the OSL 3.0 license.
Subject to Licensee's/Customer's payment of fees and compliance with the terms and conditions of the applicable ordering document between Licensee/Customer and Adobe (or Magento), the terms and conditions of the applicable ordering between Licensee/Customer and Adobe (or Magento) supersede the OSL 3.0 license for each source file.
Communications
We are dedicated to our Community and encourage your contributions and welcome feedback through events, our DevBlog, Twitter and YouTube channels, and other Community resources.
To connect with people from the Community and Adobe engineering, join us in Slack. We have a channel for every project. To join a particular channel, send us a request at engcom@adobe.com, or sign up.
If you are a new Community member, check out the following channels:
- general is an open chat for introductions and Magento 2 questions
- github is a support channel for GitHub issues, pull requests, and processes
- public-backlog for discussions of the backlog
Top Related Projects
A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.
PrestaShop is the universal open-source software platform to build your e-commerce solution.
A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot