Magento 1.6.2删除Paypal订单状态

时间:2012-04-16 09:12:58

标签: magento paypal

我正在运行Magento 1.6.2并希望删除Paypal订单状态。它们根本没有被使用,它们污染了我的订单状态列表。禁用Paypal不起作用。

Magento 1.6.2确实能够管理管理员的订单状态,但Paypal状态是不可移动的。

有没有办法从数据库中删除它们,或者只是隐藏它们?

1 个答案:

答案 0 :(得分:2)

我可以告诉您,您不想删除它们,Mage_Paypal_Model_Info使用它们来检查付款是否处于审核,欺诈,处理或完成状态。我建议你只是处理它们。它们作为const存在于某个目的,即使您可能实际上没有使用它们,但它们在幕后使用。他们做得比他们真正伤害的更好。

   /**
     * Check whether the payment is in review state
     *
     * @param Mage_Payment_Model_Info $payment
     * @return bool
     */
    public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
    {
        $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
        if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
            $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
            return !in_array($pendingReason, array('authorization', 'order'));
        }
        return false;
    }

    /**
     * Check whether fraud order review detected and can be reviewed
     *
     * @param Mage_Payment_Model_Info $payment
     * @return bool
     */
    public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
    {
        return self::isPaymentReviewRequired($payment)
            && 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
    }

    /**
     * Check whether the payment is completed
     *
     * @param Mage_Payment_Model_Info $payment
     * @return bool
     */
    public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
    {
        $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
        return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
    }

    /**
     * Check whether the payment was processed successfully
     *
     * @param Mage_Payment_Model_Info $payment
     * @return bool
     */
    public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
    {
        $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
        if (in_array($paymentStatus, array(
            self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
            self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
        ))) {
            return true;
        }
        $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
        return self::PAYMENTSTATUS_PENDING === $paymentStatus
            && in_array($pendingReason, array('authorization', 'order'));
    }

    /**
     * Check whether the payment was processed unsuccessfully or failed
     *
     * @param Mage_Payment_Model_Info $payment
     * @return bool
     */
    public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
    {
        $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
        return in_array($paymentStatus, array(
            self::PAYMENTSTATUS_DENIED, self::PAYMENTSTATUS_EXPIRED, self::PAYMENTSTATUS_FAILED,
            self::PAYMENTSTATUS_REVERSED, self::PAYMENTSTATUS_VOIDED,
        ));
    }

如果您查看app/code/core/Mage/Paypal/etc/config.xml,可以找到这个,

<sales>
    <order>
        <statuses>
            <pending_paypal translate="label">
                <label>Pending PayPal</label>
            </pending_paypal>
        </statuses>
    </order>
</sales>

但请查看app / code / core / Mage / Sales / etc / config.xml

        <!-- /**
              * @depraceted after 1.4.2, statuses are saved into sales_order_status table
              */
        -->

如果您使用1.4.2之后的版本,则应该查看数据库中的sales_order_status表,这是它们存在于config.xml中以确保向后兼容性的唯一原因。

这是添加待处理PayPal状态的部分,您可以注释/删除并将其删除,但我建议您在删除之前找出此状态的使用位置,这样您就没有任何状态看不见的冲突,您可以在app / code和lib /中使用grep -r 'sales_order_status' *来查找可能使用此表的任何内容以及何时使用Pending PayPal