致命错误:调用app/code/core/Mage/Paypal/Block/Express/Review.php中20


Fatal error: Call to a member function getPayment() on a non-object in app/code/core/Mage/Paypal/Block/Express/Review.php on line 203

从paypal重定向回来后,通过paypal express checkout进行交易时出现此错误。

我在装运方法中发现了这个错误。

我正在使用magento 1.7版本。

给出错误

的代码
 protected function _beforeToHtml()
    {
        $methodInstance = $this->_quote->getPayment()->getMethodInstance(); // here i get error
        $this->setPaymentMethodTitle($methodInstance->getTitle());
        $this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
        $this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
        $this->setShippingRateRequired(true);
        if ($this->_quote->getIsVirtual()) {
            $this->setShippingRateRequired(false);
        } else {
            // prepare shipping rates
            $this->_address = $this->_quote->getShippingAddress();
            $groups = $this->_address->getGroupedAllShippingRates();
            if ($groups && $this->_address) {
                $this->setShippingRateGroups($groups);
                // determine current selected code & name
                foreach ($groups as $code => $rates) {
                    foreach ($rates as $rate) {
                        if ($this->_address->getShippingMethod() == $rate->getCode()) {
                            $this->_currentShippingRate = $rate;
                            break(2);
                        }
                    }
                }
            }
            // misc shipping parameters
            $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
                ->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
                ->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
            ;
        }
        $this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
            ->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
        return parent::_beforeToHtml();
    }

您请明确您的问题,并在您得到错误的地方张贴代码,以便我们可以期待解决您的问题。

错误背后的原因可能是你在对象上调用getpayment()方法,而该对象没有正确初始化。