从Magento 1.6迁移到2.0的代码

问题描述:

这里第一次。从Magento 1.6迁移到2.0的代码

我正在尝试将此代码从Magento 1.6迁移到M 2.0。我必须指出,我只是掌握编程的基本知识,所以这对我来说非常困难。我已经做了一些研究,在M 2.0中发现了Mage更改为Bootstrap。并且getModel也改变了。我不想要完整的解决方案,因为我想练习。你能告诉我什么是错的吗?或者指导我一点,以便我可以自己找到它?

$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(); 
+0

@AlexPaliarush我在这篇文章中尝试过你的步骤[link] http://magento.stackexchange.com/questions/92204/magento-2-get-product-collection-in-a-custom-template-block [/链接],但我不能仍然能够将此代码迁移到magento 2.你能帮助我吗?谢谢 – David

一些事情可能会导致你在正确的方向。

首先,Magento的bootstrap进程已经发生了很大的变化,因此从简单的shell脚本中写出这种类型的代码并不像以前那么容易。这可能是可能的,但我还没有看到任何人这样做。相反,您可以创建一个Magento模块,并使用该模块向magento的控制台程序添加一条新命令。

其次,Magento中的对象使用对象管理器类实例化。但是,让事情变得更加混乱,你不是直接使用对象管理器类 - 而是需要使用自动构造器依赖注入来将对象注入到类中。如果你有兴趣,我写了一个article series

+0

非常感谢。我会搜索一下,看看你的文章。 – David

+0

你对这些有什么看法?我越来越近了? '公共功能推出(){ \t \t \t $的ObjectManager = \ Magento的\框架\软件\的ObjectManager ::的getInstance(); \t \t $ productCollection = $ objectManager-> create('Magento \ Catalog \ Model \ ResourceModel \ Product \ Collection'); \t \t $ productCollection-> load(); ($ \ this - > _ objectManager-> create('\ Magento \ Catalog \ Model \ Category'));回到顶端这篇文章中的信息适用于: return $ this - > _ response; }' – David

此信息可能帮助:https://community.magento.com/t5/Version-Upgrades/How-to-upgrade-Magento-1-9-2-to-2-0/td-p/23920

首先,chiefair发布

简短的回答,你不...

从Magento的1.x中移动到2.x是一个过程,而不是升级。

数据库模式发生了很大的变化,这个过程被称为迁移。必须导出数据,将其转换为新的数据库表格/列或根据情况丢弃。 Magento的的

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

的目录结构和内部操作已经改变了这么多,你需要与你的开发人员联系,以获得改写Magento的2.0工作模块。主题和模板也一样。

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

基本上,你会在运行实际网站的旧的1.x版本,而你移动你的数据在开发测试服务器和功能测试运行2.x的版本,直到你认为它已经准备好为真实世界使用。

而且flame1983发布

你有一些选择升级Magento的1.9.2到2.0:

  • 手动升级。这可能需要很长的时间,并得到很多的错误,但便宜

  • 聘请专家为你做。它似乎很昂贵

  • 使用迁移工具。这是一种流行的方式。我建议这个工具。它是便宜,但有效

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

希望这有助于。