0

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

Magento 1.6.2 确实具有在管理员中管理订单状态的出色能力,但 Paypal 状态是不可移除的。

有什么方法可以将它们从数据库中硬删除,或者只是以某种方式隐藏它们?

4

1 回答 1

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 状态的部分,您可以评论/删除并将其删除,但我建议您在删除之前找出此状态的使用位置,以免出现任何看不见的冲突,您可以grep -r 'sales_order_status' *在 app/code 和 lib/ 中使用来查找可能使用此表的任何内容以及何时使用Pending PayPal.

于 2012-04-16T18:41:58.197 回答