Magento EE PayPal IPN 问题:PHP 致命错误:在第 532 行 app/code/core/Mage/Paypal/Model/Ipn.php 中的非对象上调用成员函数 save()

magento.stackexchange https://magento.stackexchange.com//questions/48343

我们收到了一封来自 PayPal 的电子邮件,提醒我们我们的 IPN 页面返回了大量 500 错误。我们调查了各种错误日志,并在 /var/log/nginx 目录中发现以下错误。由于明显的原因,完整的目录路径已被删除。

PHP Fatal error:  Call to a member function save() on a non-object in app/code/core/Mage/Paypal/Model/Ipn.php on line 532"

我们正在运行 Magento Enterprise 1.13.0.2,包含第 532 行的方法位于以下函数中。

/**
 * Process completed payment (either full or partial)
 *
 * @param bool $skipFraudDetection
 */
protected function _registerPaymentCapture($skipFraudDetection = false)
{
    if ($this->getRequestData('transaction_entity') == 'auth') {
        return;
    }
    $parentTransactionId = $this->getRequestData('parent_txn_id');
    $this->_importPaymentInformation();
    $payment = $this->_order->getPayment();
    $payment->setTransactionId($this->getRequestData('txn_id'))
        ->setPreparedMessage($this->_createIpnComment(''))
        ->setParentTransactionId($parentTransactionId)
        ->setShouldCloseParentTransaction('Completed' === $this->getRequestData('auth_status'))
        ->setIsTransactionClosed(0)
        ->registerCaptureNotification(
            $this->getRequestData('mc_gross'),
            $skipFraudDetection && $parentTransactionId
        );
    $this->_order->save();

    // notify customer
    $invoice = $payment->getCreatedInvoice();
    if ($invoice && !$this->_order->getEmailSent()) {
        $this->_order->sendNewOrderEmail()->addStatusHistoryComment(
            Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
        )
        ->setIsCustomerNotified(true)
        ->save();
    }
}

第 532 行是在 $this->_order->sendNewOrderEmail()... 上调用的 save() 方法。朝向函数的底部。由于在本地环境中测试 IPN 非常困难,我想知道以前是否有人遇到过这个错误?或者他们是否能为我指明问题的正确方向。

有帮助吗?

解决方案

由于错误出现在 ->save 线,这意味着 setIsCustomerNotified(true) 不返回 $this (当前对象)。
唯一出现的情况是 setIsCustomerNotified 我发现在班级里 Mage_Sales_Model_Order_Status_History 返回 return $this->setData('is_customer_notified', $flag);.

setData 方法应该返回当前对象。
因此,自定义模块必须在您的实例中覆盖某些内容。
要么是 setIsCustomerNotified 方法或 setData 的方法 Mage_Sales_Model_Order_Status_History 班级。

这是一个简单的脚本 这可以帮助您找到实例中的覆盖。在输出中查找与以下内容相关的内容 Order 或者 History.

其他提示

您的问题可能是在 sendNewOrderEmail() 方法。这通常会被处理交易电子邮件的第三方扩展覆盖。检查是否有任何扩展程序执行此操作,并查看是否可以禁用它们进行测试。

许可以下: CC-BY-SA归因
scroll top