Skip to content

Commit 2ce2116

Browse files
committed
Fix bug introduced by previous commit
Now instead of using the helper, we are only catching the exception thrown. See previous commit for full description.
1 parent 158582a commit 2ce2116

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

app/code/Magento/Payment/Model/PaymentMethodList.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Payment\Model;
77

88
use Magento\Payment\Api\Data\PaymentMethodInterface;
9+
use UnexpectedValueException;
910

1011
/**
1112
* Payment method list class.
@@ -39,12 +40,29 @@ public function __construct(
3940
*/
4041
public function getList($storeId)
4142
{
42-
$methodsInstances = $this->helper->getStoreMethods($storeId);
43+
$methodsCodes = array_keys($this->helper->getPaymentMethods());
44+
$methodsInstances = array_map(
45+
function ($code) {
46+
try {
47+
return $this->helper->getMethodInstance($code);
48+
} catch (UnexpectedValueException $e) {
49+
return null;
50+
}
51+
},
52+
$methodsCodes
53+
);
4354

44-
$methodsInstances = array_filter($methodsInstances, function (MethodInterface $method) {
45-
return !($method instanceof \Magento\Payment\Model\Method\Substitution);
55+
$methodsInstances = array_filter($methodsInstances, function ($method) {
56+
return $method && !($method instanceof \Magento\Payment\Model\Method\Substitution);
4657
});
4758

59+
@uasort(
60+
$methodsInstances,
61+
function (MethodInterface $a, MethodInterface $b) use ($storeId) {
62+
return (int)$a->getConfigData('sort_order', $storeId) - (int)$b->getConfigData('sort_order', $storeId);
63+
}
64+
);
65+
4866
$methodList = array_map(
4967
function (MethodInterface $methodInstance) use ($storeId) {
5068

0 commit comments

Comments
 (0)