Skip to content

magento/magento2#32066: Fix duplicate customer prefix/suffix dropdown options - #41053

Open
swnsma wants to merge 1 commit into
magento:2.4-developfrom
swnsma:magento/magento2#32066
Open

magento/magento2#32066: Fix duplicate customer prefix/suffix dropdown options#41053
swnsma wants to merge 1 commit into
magento:2.4-developfrom
swnsma:magento/magento2#32066

Conversation

@swnsma

@swnsma swnsma commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description (*)

Fixes duplicate name prefix / suffix options on the customer account edit form after a value is saved and the page is reloaded.

Magento\Customer\Model\Options returns a numerically indexed list of option values. Name::getPrefixOptions() / getSuffixOptions() still used isset($options[$value]) (key lookup) and re-appended the current customer value with a string key. The template iterates values, so the selected option appeared twice.

Change: treat options as a list — membership via in_array(..., true), append missing legacy values with $options[] = .... Same for suffix. Unit tests updated to use list-shaped options and cover the no-duplicate path.

Fixed Issues (if relevant)

  1. Fixes Magento 2.4.2 - Customer prefix - Duplicate frontend and empty admin #32066

Manual testing scenarios (*)

  1. Admin → Stores → Configuration → Customers → Customer Configuration → Name and Address Options:
    • Show Prefix = Optional (or Required)
    • Prefix Dropdown Options = Mr;Mrs;Ms
  2. Login as customer → Account Information → select prefix Mr → Save → reload page.
  3. Expected: Each prefix appears once; Mr is selected (no duplicate Mr).
  4. Change prefix to Mrs → Save → reload.
  5. Expected: Mrs is selected and saved; options still unique.
  6. (Optional) Customer with legacy prefix not in config (e.g. Dr): open edit page → Dr appears once and is selected.
  7. Repeat analogous checks for suffix with options Jr;Sr.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Name options from Options model are a numerically indexed value list, but
getPrefixOptions/getSuffixOptions used isset() on array keys and re-appended
the current value, so account edit showed each selected option twice.

Check membership with in_array on values and append missing legacy values
with list append. Align unit tests with the real list option shape.
@m2-assistant

m2-assistant Bot commented Jul 27, 2026

Copy link
Copy Markdown

Hi @swnsma. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@swnsma

swnsma commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@swnsma

swnsma commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@magento run Unit Tests,Integration Tests,Functional Tests CE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Magento 2.4.2 - Customer prefix - Duplicate frontend and empty admin

2 participants