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)
-
I’ll take a look tomorrowHerve Tribouilloy– Herve Tribouilloy2024年05月16日 19:04:09 +00:00Commented May 16, 2024 at 19:04
-
If you have any third party extension of payment method, then try to disable it and then check.Dhiren Vasoya– Dhiren Vasoya2024年05月17日 04:58:19 +00:00Commented May 17, 2024 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.– Martin K.2024年05月17日 07:59:41 +00:00Commented May 17, 2024 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 indeedHerve Tribouilloy– Herve Tribouilloy2024年05月17日 08:24:39 +00:00Commented May 17, 2024 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.– Martin K.2024年05月17日 08:32:06 +00:00Commented May 17, 2024 at 8:32
3 Answers 3
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;
}
}
-
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.Juliano Vargas– Juliano Vargas2024年07月31日 09:28:23 +00:00Commented Jul 31, 2024 at 9:28
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
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>