2

After upgrading from Magento 2.4.6 to 2.4.7 I receive the following error, everytime I try to access to payment method configuration (Stores -> Configuration -> Sales -> Payment Methods):

Exception: Warning: Undefined array key "children" in /var/www/html/vendor/magento/module-payment-services-base/Plugin/MovePaymentMethods.php on line 66 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:62

Question: Any ideas to solve that issue?

Stack trace:

#1 /var/www/html/vendor/magento/module-payment-services-base/Plugin/MovePaymentMethods.php(44): Magento\PaymentServicesBase\Plugin\MovePaymentMethods->moveMethodToOtherPaymentSolutions(Array, 'express_checkou...')
#2 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\PaymentServicesBase\Plugin\MovePaymentMethods->afterModify(Object(Magento\Paypal\Model\Config\Structure\PaymentSectionModifier\Interceptor), Array, Array)
#3 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Paypal\Model\Config\Structure\PaymentSectionModifier\Interceptor->Magento\Framework\Interception\{closure}(Array)
#4 /var/www/html/generated/code/Magento/Paypal/Model/Config/Structure/PaymentSectionModifier/Interceptor.php(22): Magento\Paypal\Model\Config\Structure\PaymentSectionModifier\Interceptor->___callPlugins('modify', Array, Array)
#5 /var/www/html/vendor/magento/module-paypal/Model/Config/StructurePlugin.php(143): Magento\Paypal\Model\Config\Structure\PaymentSectionModifier\Interceptor->modify(Array)
#6 /var/www/html/vendor/magento/module-paypal/Model/Config/StructurePlugin.php(119): Magento\Paypal\Model\Config\StructurePlugin->restructurePayments(Object(Magento\Config\Model\Config\Structure\Element\Section))
#7 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Paypal\Model\Config\StructurePlugin->aroundGetElementByPathParts(Object(Magento\Config\Model\Config\Structure\Interceptor), Object(Closure), Array)
13
  • I’ll take a look tomorrow Commented May 16 at 19:04
  • If you have any third party extension of payment method, then try to disable it and then check. Commented May 17 at 4:58
  • it was a vanilla installation. I could fix that with disabling all paypal modules. But I would like to find a more easy way.
    – Martin K.
    Commented May 17 at 7:59
  • The plugin MovePaymentMethods is not enabled by anything in a vanilla install as far as I see it. In this case, 1. you should be able to disable this plugin. 2. it seems something else enables the plugin and that may be a third-party module indeed Commented May 17 at 8:24
  • strange ok I have some third-party modules but all of them are not related to MovePaymentMethods. I will investigate.
    – Martin K.
    Commented May 17 at 8:32

3 Answers 3

1

Updated File : vendor/magento/module-payment-services-base/Plugin/MovePaymentMethods.php

<?php

/************************************************************************
 *
 * Copyright 2014 Adobe
 * All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe and its suppliers, if any. The intellectual
 * and technical concepts contained herein are proprietary to Adobe
 * and its suppliers and are protected by all applicable intellectual
 * property laws, including trade secret and copyright laws.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe.
 * ************************************************************************
 */
declare(strict_types=1);

namespace Magento\PaymentServicesBase\Plugin;

use Magento\Paypal\Model\Config\Structure\PaymentSectionModifier;

class MovePaymentMethods
{
    private const RECOMMENDED_SOLUTIONS = 'recommended_solutions';
    private const CHILDREN = 'children';
    private const RECOMMENDED_SOLUTIONS_ALLOWED_LIST = ['magento_payments_legacy', 'magento_payments'];
    private const OTHER_PAYPAL_PAYMENT_SOLUTIONS = 'other_paypal_payment_solutions';

    /**
     * Move payment methods not allowed to other_paypal_payment_solutions
     *
     * @param PaymentSectionModifier $subject
     * @param array $result
     * @return array
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */

    public function afterModify(PaymentSectionModifier $subject, $result)
    {
        if (isset($result[self::RECOMMENDED_SOLUTIONS][self::CHILDREN])) {
            foreach (array_keys($result[self::RECOMMENDED_SOLUTIONS][self::CHILDREN]) as $key) {
                if (!in_array($key, self::RECOMMENDED_SOLUTIONS_ALLOWED_LIST, true)) {
                    $result = $this->moveMethodToOtherPaymentSolutions($result, $key);
                }
            }
        }

        return $result;
    }

    /**
     * Move other payment method by key to other_paypal_payment_solutions
     *
     * @param array $result
     * @param int|string $key
     * @return array
     */
    public function moveMethodToOtherPaymentSolutions(array $result, int|string $key): array
    {
        if (isset($result[self::RECOMMENDED_SOLUTIONS][self::CHILDREN][$key])) {
            if (!isset($result[self::OTHER_PAYPAL_PAYMENT_SOLUTIONS][self::CHILDREN])) {
                $result[self::OTHER_PAYPAL_PAYMENT_SOLUTIONS][self::CHILDREN] = [];
            }

$result[self::OTHER_PAYPAL_PAYMENT_SOLUTIONS][self::CHILDREN] =
    array_merge(
        [
            $result[self::RECOMMENDED_SOLUTIONS][self::CHILDREN][$key]
        ],
        $result[self::OTHER_PAYPAL_PAYMENT_SOLUTIONS][self::CHILDREN]
    );

unset($result[self::RECOMMENDED_SOLUTIONS][self::CHILDREN][$key]);
}
return $result;
}
}
1
  • Any ideas why this is happening? I have 5 websites with each having 1 store view but only one website/store is having this issue. Commented Jul 31 at 9:28
0

the problem seems to be the "new Adobe payment" plugin. The solution above "MovePaymentMethods.php" works but strangely on one server the problem did not occur after upgrade to 2.4.7

0

As a workaround, you can disable the plugin from a custom module. etc/adminhtml/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Paypal\Model\Config\Structure\PaymentSectionModifier">
        <plugin name="move_express_checkout_us_to_other_paypal_payment_solutions" disabled="true"/>
    </type>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.