Skip to content

Commit 62c5acc

Browse files
committed
MAGETWO-96432: Payment method title does not update in the admin sales order grid
- Change title definition logic for offline payment methods
1 parent b626b49 commit 62c5acc

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

app/code/Magento/Payment/Helper/Data.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,10 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit
261261
$groupRelations = [];
262262

263263
foreach ($this->getPaymentMethods() as $code => $data) {
264-
$storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
265-
if (isset($storedTitle)) {
266-
$methods[$code] = $storedTitle;
267-
} elseif (isset($data['title'])) {
264+
if (isset($data['title'])) {
268265
$methods[$code] = $data['title'];
266+
} else {
267+
$methods[$code] = $this->getMethodInstance($code)->getConfigData('title', $store);
269268
}
270269
if ($asLabelValue && $withGroups && isset($data['group'])) {
271270
$groupRelations[$code] = $data['group'];

app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Payment\Ui\Component\Listing\Column\Method;
77

8+
use Magento\Payment\Api\PaymentMethodListInterface;
9+
use Magento\Store\Model\StoreManagerInterface;
10+
811
/**
912
* Class Options
1013
*/
@@ -20,14 +23,29 @@ class Options implements \Magento\Framework\Data\OptionSourceInterface
2023
*/
2124
protected $paymentHelper;
2225

26+
/**
27+
* @var PaymentMethodListInterface
28+
*/
29+
private $paymentMethodList;
30+
31+
/**
32+
* @var StoreManagerInterface
33+
*/
34+
private $storeManager;
35+
2336
/**
2437
* Constructor
2538
*
2639
* @param \Magento\Payment\Helper\Data $paymentHelper
2740
*/
28-
public function __construct(\Magento\Payment\Helper\Data $paymentHelper)
29-
{
41+
public function __construct(
42+
\Magento\Payment\Helper\Data $paymentHelper,
43+
\Magento\Payment\Api\PaymentMethodListInterface $paymentMethodList,
44+
\Magento\Store\Model\StoreManagerInterface $storeManager
45+
) {
3046
$this->paymentHelper = $paymentHelper;
47+
$this->paymentMethodList = $paymentMethodList;
48+
$this->storeManager = $storeManager;
3149
}
3250

3351
/**
@@ -38,8 +56,23 @@ public function __construct(\Magento\Payment\Helper\Data $paymentHelper)
3856
public function toOptionArray()
3957
{
4058
if ($this->options === null) {
41-
$this->options = $this->paymentHelper->getPaymentMethodList(true, true);
59+
$this->options = $this->getPaymentOptions();
60+
// $this->options = $this->paymentHelper->getPaymentMethodList(true, true);
4261
}
4362
return $this->options;
4463
}
64+
65+
/**
66+
* @return array
67+
* @throws \Magento\Framework\Exception\NoSuchEntityException
68+
*/
69+
private function getPaymentOptions()
70+
{
71+
$options = [];
72+
foreach ($this->paymentMethodList->getList($this->storeManager->getStore()->getId()) as $option) {
73+
$options[$option->getCode()] = ['value' => $option->getCode(), 'label' => $option->getTitle()];
74+
}
75+
asort($options);
76+
return $options;
77+
}
4578
}

0 commit comments

Comments
 (0)