Is it possible to migrate code from 1.9 to 2.
Themes and extensions have to be rewritten.
There are tools that help developers converting their code but a fully automated solution is not possible.
- Official "code migration" tool: https://github.com/magento/code-migration
- M1M2 Converter by Unirgy: https://github.com/unirgy/convertm1m2
For code that's not too complex and does not depend on too many implementation details (i.e. rewrites), you might get usable results, otherwise it's at least a good starting point for configuration files and standard boilerplate code.
Also, to adhere to Magento 2 best practices you will need to change most of the converted code because it's a 1:1 mapping of models and collections and those should not be used in Magento 2 if you can do the same using the service contracts.
A general advise: Try to make as much as possible of your business logic independent from Magento, this way your critical code does not need any changes to be used in Magento 2. I wrote a series of blog articles about how to achieve this:
And also recently gave a presentation how to refactor existing extensions to decouple them from Magento:
You can't migrate code from Magento 1 to Magento 2. All extension is created in magento1 are not compatible to Magento 2. You have to create from scratch or support to third-party extension provider company for the magento2 extension.
You also not migrate from theme code. You have to create the new theme for Magento 2 because theme structure for Magento 1 is totally different from magento1.
You can only migrate orders, customers, url-rewrite, products, category and configuration settings` from Magento 1.
You have to write code again for magento 2.