memegento / module-mage
传奇回归
1.0.1
2022-08-20 10:54 UTC
Requires
- php: >=7.4
- magento/framework: *
README
本模块将来自 Magento 1 的传奇 Mage 类添加到 Magento 2。现在开发者可以在 Magento 2 中编写类似于 Magento 1 的代码,甚至无需任何更改即可将 Magento 1 代码移植到 Magento 2。
欢迎社区提交拉取请求!
要求
- PHP 7.4+
- 安装 Magento 2 CE 或 EE
安装
composer require memegento/mage
使用
Mage 类提供了一些基本方法,以便与 Magento 2 进行交互,仿佛它是 Magento 1。
$productModelLegacyWay = Mage::getModel('catalog/product'); $productModelNewWay = Mage::getModel(\Magento\Catalog\Model\Product::class); $productUrl = Mage::getUrl('catalog/product/view', ['product_id' => $productId]); Mage::log('Some message', ['context_field' => 'value'], Zend_Log::INFO); Mage::throwException('Exception message');
兼容性
- 2.4.x Magento 2 开源或 Commerce 版本