Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allmethods config source model does not always report the full list of payment methods #13460

Closed
moehrenzahn opened this issue Feb 1, 2018 · 8 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@moehrenzahn
Copy link

The Magento\Payment\Model\Config\Source\Allmethods config source model does not display every available payment method.

Preconditions

  1. Magento version 2.1.11, plain fresh installation

Steps to reproduce

  1. Enable the Cash on Delivery payment method
  2. Define a config field like this:
<field id="test" type="multiselect">
    <label>Test case for displaying all payment methods</label>
    <source_model>Magento\Payment\Model\Config\Source\Allmethods</source_model>
</field>
  1. Load the config field in the Magento backend

Expected result

  1. The enabled Cash on Delivery payment method should be visible in the config field multiselect

Actual result

  1. The Cash On Delivery payment method is not listed in the widget

Comments

I have tracked the source of the issue down to the app/code/Magento/Payment/Helper/Data.php::getPaymentMethodList() method, which does not report the full list of payment methods when $asLabelValue = true and $withGroups = true.

The issue was apparently introduced with this commit, which does not consider that a group's $labelValues[$code]['value'] might already hold payment method information:

$labelValues[$code]['value'] = null;

This is the issue for that pull request:

And this is the issue that prompted the problematic pull request:

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 1, 2018
@magento-engcom-team
Copy link
Contributor

@moehrenzahn, thank you for your report.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Fixed in 2.2.x The issue has been fixed in 2.2 release line and removed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release labels Feb 8, 2018
@okorshenko okorshenko removed the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Feb 22, 2018
@magento-engcom-team
Copy link
Contributor

@moehrenzahn The issue is already fixed in 2.2.
Closing ticket for now. Please reopen if you need any further assistance with this.

@magento-engcom-team magento-engcom-team added Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line and removed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Mar 6, 2018
@Ctucker9233
Copy link

@magento-engcom-team What are the commits for this issue?

@moehrenzahn
Copy link
Author

moehrenzahn commented May 2, 2018

I want to note that this issue is definitively still reproducible on 2.2.4. @magento-engcom-team, can you please check this.
(I am not able to reopen this issue, but please consider it reopened.)

@mashb1t
Copy link
Member

mashb1t commented May 7, 2018

@magento-engcom-team
We also could reproduce the issue on 2.2.4. This malfunction happens only when $withGroups is true.
When adding the group, the mentioned line of code "$labelValues[$code]['value'] = null;" causes the already set method values to be overridden. Due to sorting the array alphabetically first, the group "offline" e.g. overrides four already set values such as "checkmo".

A quick fix would be to only set the value if it doesn't already exist (fixed in src/vendor/magento/module-payment/Helper/Data.php lines 296-298)

if (!isset($labelValues[$code]['value'])) {
$labelValues[$code]['value'] = null;
}

@mashb1t mashb1t reopened this May 7, 2018
mashb1t added a commit to mashb1t/magento2 that referenced this issue May 7, 2018
@magento-engcom-team
Copy link
Contributor

Hi @moehrenzahn. Thank you for your report.
The issue has been fixed in #15032 by @mash1t in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.5 release.

@magento-engcom-team
Copy link
Contributor

Hi @moehrenzahn. Thank you for your report.
The issue has been fixed in #15134 by @mzeis in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@sylvainraye
Copy link
Contributor

FYI it will be released in 2.2.6 we see that the PR is merged only in this version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

6 participants