This directory holds the code for the Migrate Magento to Medusa Guide.
You can either:
- install and use it as a plugin in the Medusa application;
- or copy its source files into an existing Medusa application, without using them as a plugin.
Then, learn how to test it out in the Test it Out section.
- Node.js v20+
- Git CLI
- PostgreSQL
- Magento server with admin credentials.
Learn more about building and developing with plugins in this documentation.
- Clone the repository and change to the
migrate-from-magentodirectory:
git clone https://github.com/medusajs/examples.git
cd examples/migrate-from-magento2. Install dependencies:
yarn install # or npm install3. Publish to local registry:
npx medusa plugin:publish4. Build plugin:
npx medusa plugin:build5. In a Medusa application, install the plugin from the local registry:
npx medusa plugin:add migrate-from-magento6. Add the plugin to medusa-config.ts:
module.exports = defineConfig({
// ...
plugins: [
{
resolve: "migrate-from-magento",
options: {
baseUrl: process.env.MAGENTO_BASE_URL,
username: process.env.MAGENTO_USERNAME,
password: process.env.MAGENTO_PASSWORD,
migrationOptions: {
imageBaseUrl: process.env.MAGENTO_IMAGE_BASE_URL,
}
},
},
],
})7. Set the following environment variables:
MAGENTO_BASE_URL=https://magento.example.com
MAGENTO_USERNAME=admin
MAGENTO_PASSWORD=password
MAGENTO_IMAGE_BASE_URL=https://magento.example.com/pub/media/catalog/productWhere:
MAGENTO_BASE_URL: The base URL of the Magento server. It can also be a local URL, such ashttp://localhost:8080.MAGENTO_USERNAME: The username of a Magento admin user to authenticate with the Magento server.MAGENTO_PASSWORD: The password of the Magento admin user.MAGENTO_IMAGE_BASE_URL: The base URL to use for product images. Magento stores product images in thepub/media/catalog/productdirectory, so you can reference them directly or use a CDN URL. If the URLs of product images in the Medusa server already have a different base URL, you can omit this option.
You can also copy the source files into an existing Medusa application, which will add them not as a plugin, but as standard Medusa customizations.
- Copy the content of the following directories:
src/adminsrc/api/adminandsrc/api/middlewares.tssrc/jobssrc/modules/magentosrc/modules/subscriberssrc/workflows
- Add the Magento Module to
medusa-config.ts:
module.exports = defineConfig({
// ...
modules: [
{
resolve: "./src/modules/magento",
options: {
baseUrl: process.env.MAGENTO_BASE_URL,
username: process.env.MAGENTO_USERNAME,
password: process.env.MAGENTO_PASSWORD,
migrationOptions: {
imageBaseUrl: process.env.MAGENTO_IMAGE_BASE_URL,
}
}
},
]
})- Set the following environment variables:
MAGENTO_BASE_URL=https://magento.example.com
MAGENTO_USERNAME=admin
MAGENTO_PASSWORD=password
MAGENTO_IMAGE_BASE_URL=https://magento.example.com/pub/media/catalog/productWhere:
MAGENTO_BASE_URL: The base URL of the Magento server. It can also be a local URL, such ashttp://localhost:8080.MAGENTO_USERNAME: The username of a Magento admin user to authenticate with the Magento server.MAGENTO_PASSWORD: The password of the Magento admin user.MAGENTO_IMAGE_BASE_URL: The base URL to use for product images. Magento stores product images in thepub/media/catalog/productdirectory, so you can reference them directly or use a CDN URL. If the URLs of product images in the Medusa server already have a different base URL, you can omit this option.
To test out that the customizations are working, open the Medusa Admin at http://localhost:9000/app. You'll find a "Migrate Magento" sidebar item. Click on it, and you can trigger a migration of products and categories.