Magento 1 to Magento 2 Migration
Magento 1 has been officially unsupported since June 2020. Migrating to Magento 2 is not an update but a complete rebuild: different architecture, different data formats, different extension system. The official Data Migration Tool will transfer data, but all code for themes and modules must be rewritten from scratch or equivalents found.
What Migrates, What Doesn't
| Component | Status |
|---|---|
| Products, categories, attributes | Migrate via Data Migration Tool |
| Customers and passwords | Customers migrate, passwords don't (hashing algorithm changed) |
| Orders and history | Migrate |
| CMS pages and blocks | Migrate |
| Themes (templates) | Don't migrate — Magento 2 uses PHTML + Knockout.js + LESS |
| Extensions | Don't migrate — Magento 2 API is incompatible |
| Custom database tables | Require manual migration |
| URL rewrites | Migrate with caveats |
Migration Stages
1. Magento 1 Audit
Extension inventory is the most critical stage:
# List installed extensions
find /var/www/m1 -name "*.xml" -path "*/etc/config.xml" | \
grep -v "Mage\|Phoenix\|Enterprise" | head -50
# List custom code in app/local and app/community
ls /var/www/m1/app/code/local/
ls /var/www/m1/app/code/community/
For each extension, find a Magento 2 equivalent or estimate rewriting cost.
2. Install Magento 2 and Data Migration Tool
# Install Magento 2
composer create-project --repository-url=https://repo.magento.com/ \
magento/project-community-edition /var/www/m2
# Install Data Migration Tool
composer require magento/data-migration-tool
# Config: app/etc/env.php (M2 connection)
# Migrator config.xml
cp vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.1/config.xml.dist \
app/etc/migration-config.xml
Edit migration-config.xml — specify both connections (M1 and M2), source version.
3. Configure Mapping
<!-- app/etc/migration-config.xml -->
<config xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:noNamespaceSchemaLocation="urn:magento:module:Magento_DataMigrationTool:etc/config.xsd">
<steps mode="data">
<step title="Settings Step">
<integrity>Magento\DataMigration\Step\Settings\Integrity</integrity>
<run>Magento\DataMigration\Step\Settings\Data</run>
</step>
</steps>
<source>
<database host="localhost" name="magento1_db" user="root" password="pass"/>
</source>
<destination>
<database host="localhost" name="magento2_db" user="root" password="pass"/>
</destination>
<options>
<bulk_size>100</bulk_size>
<custom_option_map>false</custom_option_map>
<source_prefix></source_prefix>
<dest_prefix></dest_prefix>
</options>
</config>
4. Run Settings Migration
# Check settings (read-only)
php bin/magento migrate:settings --config=app/etc/migration-config.xml
# Migrate store configuration
php bin/magento migrate:settings --config=app/etc/migration-config.xml --stage=data
5. Data Migration
# Integrity check (before running!)
php bin/magento migrate:check --config=app/etc/migration-config.xml --stage=data
# If check passes — run data migration
php bin/magento migrate:data --config=app/etc/migration-config.xml
# Incremental migration (delta) to sync new orders
php bin/magento migrate:delta --config=app/etc/migration-config.xml
Large catalog migration (100k+ products) takes hours. Run via screen or tmux:
screen -S migration
php bin/magento migrate:data --config=app/etc/migration-config.xml 2>&1 | tee /var/log/migration.log
# Ctrl+A D to detach
6. Custom Attribute Mapping
If M1 had custom attributes with specific codes or types:
<!-- vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.1/map-eav.xml -->
<map>
<source>
<field_rules>
<ignore>
<field>catalog_product/my_custom_attr_old_name</field>
</ignore>
</field_rules>
</source>
<destination>
<field_rules>
<transform>
<field>catalog_product/new_attr_name</field>
<handler class="Magento\DataMigration\Handler\SetValue">
<param name="value" value="default_value"/>
</handler>
</transform>
</field_rules>
</destination>
</map>
Custom Table Migration
Data Migration Tool doesn't know about extension custom tables. For these — manual SQL script:
<?php
// migrate_custom_data.php
$m1 = new PDO('mysql:host=localhost;dbname=magento1', 'root', 'pass');
$m2 = new PDO('mysql:host=localhost;dbname=magento2', 'root', 'pass');
// Example: migrate custom reviews
$stmt = $m1->query("SELECT * FROM custom_reviews WHERE status = 1");
$reviews = $stmt->fetchAll(PDO::FETCH_ASSOC);
$insert = $m2->prepare(
"INSERT INTO custom_reviews (product_id, customer_id, text, rating, created_at)
VALUES (:product_id, :customer_id, :text, :rating, :created_at)
ON DUPLICATE KEY UPDATE text = :text"
);
foreach ($reviews as $review) {
$insert->execute($review);
}
Customer Password Problem
M1 uses MD5-hash passwords, M2 uses bcrypt. After migration, customers need to reset passwords. Options:
- Force reset — send all customers email with password reset link
- Lazy migration — on first login check old MD5, if matches — re-hash via bcrypt and save
// Plugin for CustomerAuthenticationService
public function aroundAuthenticate($subject, callable $proceed, $username, $password)
{
try {
return $proceed($username, $password); // Try standard bcrypt
} catch (AuthenticationException $e) {
// Check legacy MD5
$customer = $this->customerRepository->get($username);
$legacyHash = md5($password); // simplified, M1 used salt
if (hash_equals($customer->getLegacyPasswordHash(), $legacyHash)) {
// Update to bcrypt
$this->customerRepository->save(
$customer->setPasswordHash($this->encryptor->getHash($password, true))
);
return $customer;
}
throw $e;
}
}
Transitioning from OCMOD/Connect to Composer
All M1 extensions are installed via Magento Connect or file patches. In M2 — only Composer. For each extension:
- Find equivalent on marketplace.magento.com or Packagist
- If no equivalent — write module from scratch for M2 API
# Install extension via Composer
composer require vendor/module-name
# Enable module
php bin/magento module:enable Vendor_ModuleName
php bin/magento setup:upgrade
SEO: URL Preservation
M1 and M2 have different URL formats. Need to generate 301 redirects:
-- Get old URLs from M1
SELECT request_path, target_path, options
FROM core_url_rewrite
WHERE store_id = 1
AND id_path NOT LIKE 'product/%' -- exclude auto-generated
ORDER BY request_path;
After generating URLs in M2 — compare and create redirects in Nginx or via M2 URL Rewrites.
Final Synchronization (Delta Migration)
While M1 runs in production, new orders continue arriving. After DNS switch:
# Stop M1, run final delta migration
php bin/magento migrate:delta --config=app/etc/migration-config.xml
# Reindex
php bin/magento indexer:reindex
# Deploy static content
php bin/magento setup:static-content:deploy ru_RU en_US -f
php bin/magento cache:flush
Timeline
Magento 1 data migration (up to 50k products) — 2–3 days. Full project with theme rework, extension porting and testing — 2–4 months depending on M1 custom code volume.







