Welcome to migrating from Magento one
to Magento two episode four, migrating your custom code.
My name is Brent Peterson I'm a Magento Architect
and Evangelist for Wagento Creative.
In this video, we will discuss the steps needed
in migrating your custom code from your magenta one store.
In most cases, your custom code will not be compatible
with your Magento two store
to be more specific if your code is written correctly
in magenta one, it will not work in Magento two
and it will need to be refactored
in your new Magento two store, but there is hope,
the hope is your Magento migration tool.
Magento provides a code migration toolkit
that can help you in this process.
You can find the toolkit on GitHub
with the link provided in this video.
The Code Migration Toolkit provides scripts
that can ease the process of converting custom code
in Magento one to Magento two by handling
some of the most time-consuming conversion tasks.
The toolkit is intended for Magento developers
with a reasonable expertise in both Magento one
and Magento two, let's go over a little bit
how to use the toolkit.
The migration toolkit will cover the following areas
in your existing magenta one module.
The directory structure of your module,
the layout of XML files, the layout of your config files
and your PHP files.
The migration of Magento modules
is the focus of the toolkit
Magento themes are out of scope for this toolkit.
The good news is the toolkit can cover
and will reduce work needed to migrate your code
from a Magento one to Magento two.
The toolkit is an automated tool and will require editing
and testing your files after the migration
and this is a great time to write your unit tests
on your new code after the migration has happened.
Let's look at some requirements for your system
PHP 7.1 is the main requirement
your old system may be using an older version of PHP.
So you should do this migration
on your target Magento two system
that you will be using for your upgrade.
Composer is a necessary requirement
and PHP unit is a requirement.
There are a number of other items that will be recognized
in the command line tool during your installation.
Let's go over the basic steps in your migration
you will first migrate your module structure,
next, you will migrate your layout XML files,
next will be your config XML files.
Finally, the tool or migrate your PHP code
and we'll preserve the business logic of that code
of course this assumes your existing code
is written correctly.
Running your code migration tool
will look something like this.
Step one is migrating your directory structure,
next we'll be migrating your XML files for layout,
next will be migrating your config XML
and finally we will migrate your PHP code.
The migration scripts are to be run in the specified order
as the output from one script may be used to input
for the other scripts.
The scripts read the Magento one code
from the source directory, convert it
and write the transformed code to the destination directory.
All converted code is saved to files
with extension converted extension.
The directory is M one and M two are used
to look up the context of the code to be migrated.
You will find the documentation
for the code and all the details
within the tool on the link provided.
Let's take a brief look at core hacks
the tool will not cover core hacks.
So you will need to identify these in advance
you can move core hacks to your local mates directory
but I would recommend investigating why the core hacks
are there and determine if you still need these features
in your new environment.
Improperly written code can introduce security risks
you'll want to check the code before you move it
code that is incorrectly written will not be moved.
You should identify all this code and do not migrate
to your new system in the same way
it was written in the old.
Do not migrate bad code to your new system
the site migration process is also a good time
to identify stray code.
Your site may have third-party plugins
that reside in the root of your site
this is a good time to rewrite this code
to fit to the Magento two framework.
You may have API integrations that are incorrect
and you may have direct database access
outside what is best practice in Magento.
None of these items will be migrated
and will need to be refactored during this process.
All of these code migration items that are outside
of the scope of the tool must be done manually.
Thank you for watching this video
our next video will be episode five data migration tool.