Skip to content

Issue 32793 Add has_options and required_options to grapql Product Interface - #33125

Open
karyna-t wants to merge 3 commits into
magento:2.4-developfrom
karyna-t:issue-32793-add-has-options-and-required-options-to-grapql-product-interface
Open

Issue 32793 Add has_options and required_options to grapql Product Interface#33125
karyna-t wants to merge 3 commits into
magento:2.4-developfrom
karyna-t:issue-32793-add-has-options-and-required-options-to-grapql-product-interface

Conversation

@karyna-t

@karyna-t karyna-t commented Jun 2, 2021

Copy link
Copy Markdown
Contributor

Description (*)

Add has_options and required_options to grapql ProductInterface

Fixed Issues (if relevant)

  1. Fixes Attributes has_options and required_options are not available in GraphQL #32793

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)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

@m2-assistant

m2-assistant Bot commented Jun 2, 2021

Copy link
Copy Markdown

Hi @karyna-tsymbal-atwix. Thank you for your contribution
Here are 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
  13. Semantic Version Checker

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

@magento-engcom-team magento-engcom-team added Component: CatalogGraphQl Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Jun 2, 2021
@karyna-t

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@magento-automated-testing

Copy link
Copy Markdown

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@karyna-t

Copy link
Copy Markdown
Contributor Author

@magento run Functional Tests B2B

@magento-automated-testing

Copy link
Copy Markdown

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@eduard13 eduard13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @karyna-tsymbal-atwix, could you please review the minor suggestion below?
Thank you.

namespace Magento\GraphQl\Catalog;

use Magento\TestFramework\TestCase\GraphQlAbstract;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a class description

/**
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_custom_options.php
*/
public function testHasOptionsAndRequiredOptionsAttribute()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
public function testHasOptionsAndRequiredOptionsAttribute()
public function testHasOptionsAndRequiredOptionsAttribute(): void

Comment on lines +33 to +34
self::assertArrayHasKey('has_options', $response['products']['items'][0]);
self::assertArrayHasKey('required_options', $response['products']['items'][0]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self::assertArrayHasKey('has_options', $response['products']['items'][0]);
self::assertArrayHasKey('required_options', $response['products']['items'][0]);
$this->assertArrayHasKey('has_options', $response['products']['items'][0]);
$this->assertArrayHasKey('required_options', $response['products']['items'][0]);

products(filter: {sku: {eq: "{$productSku}"}}) {
items {
sku
has_options

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
has_options
has_options

@eduard13 eduard13 added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Jul 22, 2021
@karyna-t

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@magento-automated-testing

Copy link
Copy Markdown

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@karyna-t

Copy link
Copy Markdown
Contributor Author

@magento run Integration Tests

@magento-automated-testing

Copy link
Copy Markdown

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@karyna-t

Copy link
Copy Markdown
Contributor Author

@magento run Functional Tests EE

@magento-automated-testing

Copy link
Copy Markdown

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-engcom-team

Copy link
Copy Markdown
Contributor

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

@eduard13 eduard13 added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jul 23, 2021
@magento-engcom-team

Copy link
Copy Markdown
Contributor

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

categories: [CategoryInterface] @doc(description: "The categories assigned to a product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoriesIdentity")
canonical_url: String @doc(description: "Relative canonical URL. This value is returned only if the system setting 'Use Canonical Link Meta Tag For Products' is enabled") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
media_gallery: [MediaGalleryInterface] @doc(description: "An array of Media Gallery objects.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\MediaGallery")
has_options: Boolean @doc(description: "Indicates whether additional options have been created for the product.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't this be wrapped in an interface?
we do have CustomizableProductInterface and this can be used as a fragment
in this interface we have
options: [CustomizableOptionInterface]
which has_options can be as simple as is_empty(options)
and required_options will be inside CustomizableOptionInterface for each option required: Boolean
So what is the real need for these 2 fields what we can't achieve it the existing way?

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Hi @karyna-t, this PR was approved twice in 2021 and only needs a rebase now (the schema.graphqls hunk conflicts with custom_attributesV2 added since). Issue #32793 is still open and the fields are still missing from ProductInterface on 2.4-develop.

If you are still around and want to finish it, please go ahead. Otherwise I will open a fresh PR from my fork with your commits preserved and credited, and link it here.

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Opened #41215 with these commits rebased onto current 2.4-develop and credited to @karyna-t. Happy to close it in favour of this one if the author returns.

@karyna-t

karyna-t commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi @lbajsarowicz, feel free to open a fresh PR from your fork. Thanks!

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Thank you @karyna-t. #41215 carries your commits with authorship preserved; I will take it through CI from here.

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: CatalogGraphQl Partner: Atwix Pull Request is created by partner Atwix 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. Progress: pending review Release Line: 2.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attributes has_options and required_options are not available in GraphQL

7 participants