如何找到调用另一个Magento对象的实例';的方法


How can I find the instance calling another Magento object's method from within that object?

一位客户要求我降低Magento …/template/checkout/cart/shipping.phtml的复杂性,使其只要求提供(美国)邮政编码,绕过国家地区。然后进一步假设第一个运输选项。(订单由客户在管理员中确定)。为了做到这一点,我需要重写…/Mage/Checkout/controllers/CartController.php中的estimatePostAction方法,以便它假定estimateUpdatePostAction(来自同一类)的结果。

我一直在努力选择第一个运输选项。

我遇到的问题是,有效装运值是通过$this->getEstimateRates()上的循环在shipping.html模板中计算的。如何从覆盖的CartController类中获取由$this表示的对象,以便计算运输选项?

注:这是Magento EE版本1.11.2.0

如果你找到上面的tl;博士,这是我要做的一个总结:

  • 覆盖签出/购物车/运输模板,以便:
    • 仅要求提供邮政编码
    • 无需询问即可自动选择第一个可用的有效运输选项

/Mage/Checkout/controllers/CartController.php中,您可以通过以下方式访问/template/checkout/cart/shipping.phtml$this->getEstimateRates())中的装运值:

Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getGroupedAllShippingRates();

$this->getQuote()->getShippingAddress()->getGroupedAllShippingRates()将退还您收取的运费。不过我自己还没试过。