use_models_inside_template(phtml)
让我们不在模板或任何地方使用对象管理器,但是获取任何类的对象引用的最简单方法是:
$ mergedCells =($ this-> helper(Magento \ Tax \ Helper \ Data :: class)-> displayCartBothPrices()?2:1);
获取结帐会话:$ checkoutSession = $ this-> helper(Magento \ Checkout \ Helper \ Data :: class)-> getCheckout();
购物车,客户和所有其他班级文件也是如此
$ object = $ this-> helper(供应商\模块名称\ Helper \ Data :: class)-> function();
Helper类为所有类型的类提供