Migrating code from Magento 1.6 to 2.0

539 Views Asked by At

first time here.

I am trying to migrate this code from Magento 1.6 to M 2.0. I have to note that I just have basic knowledge with programming so this is very hard for me. I have done some research where I found Mage change to Bootstrap in M 2.0. and getModel have changed also. I am not asking for the complete solution as I want to practice. Can you tell me what things are wrong or guide me a little so I can find it by myself?

$mageFilename = '../app/Mage.php';
require_once $mageFilename;

umask(0);

Mage::app('default');
$intRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$objCategories = Mage::getModel('catalog/category')->getCollection();
$arrCategories = array();
2

There are 2 best solutions below

2
On

A couple of thing that might steer you in the right direction.

First, Magento's bootstrap process has changed enough that writing these sorts of one off simple shell scripts isn't quite as easy as it once was. It might be possible, but I haven't seen anyone do it yet. Instead, you can create a Magento module, and use that module to add a new command to magento's bin/magento console program.

Second, objects in Magento are instantiated using an object manager class. However, making things a bit more confusing, you're not meant to use the object manager class directly -- instead you need to use automatic constructor dependency injection to inject the objects into your classes. I wrote an article series that covers this if you're interested.

0
On

This post might help: https://community.magento.com/t5/Version-Upgrades/How-to-upgrade-Magento-1-9-2-to-2-0/td-p/23920

First, chiefair posted

Short answer, you don't...

Moving from Magento 1.x to 2.x is a process, not an upgrade.

The database schema changes so much that the process is referred to as Migration. The data has to be exported, translated to the new database tables/columns or discarded as applicable.

https://github.com/magento/data-migration-tool-ce/blob/master/README.md

The directory structure and internal operations of Magento have changed so much that you will need to check with your developers to get modules rewritten to work with Magento 2.0. Same goes for themes and templates.

http://devdocs.magento.com/guides/v2.0/migration/bk-migration-guide.html

Basically, you will be running the old 1.x version on your live site while you move your data to the 2.x version running on a development test server and function testing until you think it's ready for real world use.

And flame1983 posted

You have some choices to upgrade Magento 1.9.2 to 2.0 :

  • Upgrade it manually. It may take a lot of time and get a lot of bugs but cheap

  • Hire an expert to do it for you. It seems to be expensive

  • Use a migration tool. It is a popular way. I suggest this tool. It is cheap but effective

https://www.magentocommerce.com/magento-connect/magento-to-magento-migration-tool.html

Hope this helps.