yireo-training / magento2-mage-god
dev-master
2019-05-10 06:38 UTC
Requires
- php: >=7.0.0
- magento/framework: *
Requires (Dev)
- composer/composer: *@dev
- phpunit/phpunit: *
This package is not auto-updated.
Last update: 2024-09-30 16:06:14 UTC
README
这是一个小包,它将 Magento 1 的 Mage
类重新引入到 Magento 2 中。
免责声明
我们**不推荐**在实际情况中使用此包:这是一个教育性的噱头,并不适用于现实生活。你可能会说,在 M2 中有一个 Mage
类可以使从 M1 迁移到 M2 更容易,但这并不正确:M2 的代码有很大的不同,任何 M1 扩展、主题或自定义代码都需要重写。我们强烈建议正确地重写这些代码,利用 M2 的现代结构。这个 Mage
类并不属于这一部分。它只是一个玩笑。
安装
运行以下命令
composer require yireo/magento2-mage-god@dev
./bin/magento module:enable Yireo_MageGod
./bin/magento setup:upgrade
在您的代码中使用它
use Yireo\MageGod\Mage; use Magento\Catalog\Model\Product; use Magento\Customer\Model\Session as CustomerSession; class Example { public function getProduct() { $product = Mage::getModel(Product::class); $product->load(42); return $product; } public function getCustomerSession() { $customerSession = Mage::getSingleton(CustomerSession::class); return $customerSession; } }