Skip to content

Customer Attributes Options with option group fixed #30421

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

Merged

Conversation

nitishcs6
Copy link
Contributor

@nitishcs6 nitishcs6 commented Oct 10, 2020

\Magento\Customer\Ui\Component\Listing\AttributeRepository::getOptionArray method fails to return correct options for attribute with option groupsi.e store_id (Create In).

Description (*)

\Magento\Customer\Ui\Component\Listing\AttributeRepository::getOptionArray method fails to return correct options for attribute with option groupsi.e store_id (Create In).
It fails for all attributes with option group in "options" index.

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Use the \Magento\Customer\Ui\Component\Listing\AttributeRepository in any form or grid and render select options with option groups.

$this->attributeRepository->getMetadataByCode($code)
Before

{
  "attribute_code": "store_id",
  "frontend_input": "select",
  "frontend_label": "Create In",
  "backend_type": "static",
  "options": [
    {
      "label": "MyStore Saudi",
      "value": null,
      "__disableTmpl": true
    },
    {
      "label": "MyStore Saudi Store",
      "value": null,
      "__disableTmpl": true
    },
    {
      "label": "MyStore Kuwait",
      "value": null,
      "__disableTmpl": true
    },
    {
      "label": "MyStore Kuwait Store",
      "value": null,
      "__disableTmpl": true
    }
  ],
  "is_used_in_grid": false,
  "is_visible_in_grid": false,
  "is_filterable_in_grid": false,
  "is_searchable_in_grid": false,
  "validation_rules": [],
  "required": true,
  "entity_type_code": "customer"
}

After

{
  "attribute_code": "store_id",
  "frontend_input": "select",
  "frontend_label": "Create In",
  "backend_type": "static",
  "options": [
    {
      "label": "MyStore Saudi",
      "value": null,
      "__disableTmpl": true
    },
    {
      "label": "    MyStore Saudi Store",
      "value": [
        {
          "label": "Saudi English",
          "value": "2",
          "__disableTmpl": true
        },
        {
          "label": "Saudi Arabic",
          "value": "3",
          "__disableTmpl": true
        }
      ],
      "__disableTmpl": true
    },
    {
      "label": "MyStore Kuwait",
      "value": null,
      "__disableTmpl": true
    },
    {
      "label": "MyStore Kuwait Store",
      "value": [
        {
          "label": "Kuwait English",
          "value": "4",
          "__disableTmpl": true
        },
        {
          "label": "Kuwait Arabic",
          "value": "5",
          "__disableTmpl": true
        }
      ],
      "__disableTmpl": true
    }
  ],
  "is_used_in_grid": false,
  "is_visible_in_grid": false,
  "is_filterable_in_grid": false,
  "is_searchable_in_grid": false,
  "validation_rules": [],
  "required": true,
  "entity_type_code": "customer"
}

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)

Resolved issues:

  1. resolves [Issue] Customer Attributes Options with option group fixed #30422: Customer Attributes Options with option group fixed

@m2-assistant
Copy link

m2-assistant bot commented Oct 10, 2020

Hi @nitishcs6. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ 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

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@nitishcs6
Copy link
Contributor Author

@magento create issue

@nitishcs6
Copy link
Contributor Author

#dmcdindia2020

@sivaschenko sivaschenko added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Oct 10, 2020
@rogyar rogyar self-assigned this Oct 10, 2020
Copy link
Contributor

@rogyar rogyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nitishcs6.Thank you for your contribution. According to the definition of done all changes should be covered by autotests. Could I ask you to cover your changes with an integration test, please?

Thank you!

@rogyar
Copy link
Contributor

rogyar commented Oct 10, 2020

@magento run all tests

@engcom-Charlie
Copy link
Contributor

Hi @nitishcs6 could you please cover your changes by integration tests?
Thank you.

@milindsingh
Copy link
Member

Hi @nitishcs6 could you please cover your changes by integration tests?
Thank you.

@engcom-Charlie can you suggest any sample integration test case for this pr?

@ghost ghost removed the Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. label Oct 20, 2020
@engcom-Charlie
Copy link
Contributor

@nitishcs6 @milindsingh unfortunately there is no integration test for \Magento\Customer\Ui\Component\Listing\AttributeRepository but feel free to create it.
You can assert the output of \Magento\Customer\Ui\Component\Listing\AttributeRepository::getMetadataByCode('store_id').
Let me know if you will have any question.

@engcom-Charlie
Copy link
Contributor

Hi, @nitishcs6 please cover your changes by integration tests. Otherwise, we can't proceed with your PR.
Thank you.

@milindsingh
Copy link
Member

@engcom-Charlie I will add the test cases this weekend.

@engcom-Charlie
Copy link
Contributor

@nitishcs6 @milindsingh do you have any updates about test coverage?
Thank you.

@engcom-Charlie
Copy link
Contributor

@nitishcs6 @milindsingh please cover your changes by integration test. Otherwise, we can't proceed with your PR.
Thank you.

@engcom-Charlie
Copy link
Contributor

@nitishcs6 @milindsingh I will take care of automated tests.
Thank you.

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-8465 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Nov 18, 2020

✔️ QA Passed

Preconditions:

(for example)

Main Website:

  1. Main Website Store:
  • Default Store View ;
  • Second Store View;
  • Third Store View;
  1. Second Store:
  • English Store View;
  • French Store View;

Screenshot from 2020-11-18 10-24-10

Manual testing scenario:

  1. Use the \Magento\Customer\Ui\Component\Listing\AttributeRepository in any form or grid and render select options with option groups;
  2. $this->attributeRepository->getMetadataByCode($code)

Before: ✖️ the method doesn't return correct options

$test = {array} [12]
 attribute_code = "store_id"
 frontend_input = "select"
 frontend_label = "Create In"
 backend_type = "static"
 options = {array} [3]
  0 = {array} [3]
   label = "Main Website"
   value = null
   __disableTmpl = true
  1 = {array} [3]
   label = "    Main Website Store"
   value = null
   __disableTmpl = true
  2 = {array} [3]
   label = "    Second Store"
   value = null
   __disableTmpl = true
 is_used_in_grid = false
 is_visible_in_grid = false
 is_filterable_in_grid = false
 is_searchable_in_grid = false
 validation_rules = {array} [0]
 required = true
 entity_type_code = "customer"

After: ✔️ the method returns correct options

$test = {array} [12]
 attribute_code = "store_id"
 frontend_input = "select"
 frontend_label = "Create In"
 backend_type = "static"
 options = {array} [3]
  0 = {array} [3]
   label = "Main Website"
   value = {array} [0]
   __disableTmpl = true
  1 = {array} [3]
   label = "    Main Website Store"
   value = {array} [3]
    0 = {array} [3]
     label = "    Default Store View"
     value = "1"
     __disableTmpl = true
    1 = {array} [3]
     label = "    Second Store View"
     value = "2"
     __disableTmpl = true
    2 = {array} [3]
     label = "    Third Store View"
     value = "3"
     __disableTmpl = true
   __disableTmpl = true
  2 = {array} [3]
   label = "    Second Store"
   value = {array} [2]
    0 = {array} [3]
     label = "    English Store View"
     value = "4"
     __disableTmpl = true
    1 = {array} [3]
     label = "    French Store View"
     value = "5"
     __disableTmpl = true
   __disableTmpl = true
 is_used_in_grid = false
 is_visible_in_grid = false
 is_filterable_in_grid = false
 is_searchable_in_grid = false
 validation_rules = {array} [0]
 required = true
 entity_type_code = "customer"

@m2-assistant
Copy link

m2-assistant bot commented Nov 27, 2020

Hi @nitishcs6, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team merged commit 3378823 into magento:2.4-develop Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Customer Event: dmcdindia2020 Partner: Born Group partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Customer Attributes Options with option group fixed
9 participants