从客户我的帐户取消Magento订单的致命错误

时间:2017-11-10 07:03:40

标签: php magento

我在取消订单时从我的magento 1.9收到错误。我正在使用commercebees扩展来扩展客户我的帐户部分的取消选项

扩展程序网址:https://www.commercebees.com/order-cancellation-module-make-it-easy-for-your-customers/

致命错误:在第46行的/public_html/app/code/core/Mage/Payment/Model/Observer.php中调用boolean上的成员函数getMethodInstance()

1 个答案:

答案 0 :(得分:0)

错误在app / code / core / Mage / Payment / Model / Observer.php的行中:

use Illuminate\Database\Eloquent\Model;

// This thing just appends some custom attributes dynamically in the JSON and array forms. And no, 'user' is not a custom attribute key.

abstract class HasTypeModelAbstract extends Model {

public function newFromBuilder($attributes = array(), $connection = NULL) {
    $instance = parent::newFromBuilder($attributes);
    $instance->appendCustomAttributes();
    return $instance;
}

protected function appendCustomAttributes() {
    $this->append( $this->getCustomAttributesFromType() );
}

public function getCustomAttributesFromType() {
    if ($this->type) {
        return $this->type->custom_attributes ?
                array_keys((array) $this->type->custom_attributes) : [];
    } else {
        return [];
    }
}

protected function setCustomAttributesFromType($attributes = array()) {
    if ($this->type) {
        $custom_attribute_keys = $this->getCustomAttributesFromType();
        $custom_attributes = (array) $this->custom_attributes ?: [];
        foreach ($custom_attribute_keys as $key) {
            $attributes[$key] = array_get($custom_attributes, $key);
        }
    }
    return $attributes;
}

protected function addMutatedAttributesToArray(array $attributes, array $mutatedAttributes) {

    $this->appendCustomAttributes($this, $attributes);
    $attributes = $this->setCustomAttributesFromType($attributes);
    return parent::addMutatedAttributesToArray($attributes, $mutatedAttributes);
}

protected function mutateAttribute($key, $value)
{
    $keys = $this->getCustomAttributesFromType();
    if ( in_array($key, $keys) ) {
        return $this->getCustomAttributeValue( $key, $value );
    }
    return parent::mutateAttribute($key, $value);
}

protected function getCustomAttributeValue($key, $value) {
    $custom_attributes = (array) $this->custom_attributes ?: [];
    return array_get($custom_attributes, $key, $value);
}

这意味着if ($order->getPayment()->getMethodInstance()->getCode() != 'free') { 返回false。

您可以尝试验证:

  1. 如果您需要取消的订单具有正确的付款方式。也许付款方式是自定义的或定制的。在取消订单时尝试验证是否有相同的错误,其他付款方式具有相同的错误。
  2. 尝试在app / etc / modules目录中禁用其配置文件中的commercebees扩展。设置$order->getPayment()
  3. 如果Magento默认取消(从管理面板),订单可以正常运行。
  4. 如果由于businessbees扩展而发生错误,您可以向其支持团队申请帮助。