Skip to content

Add has_options and required_options to GraphQL ProductInterface (#32793) - #41215

Open
lbajsarowicz wants to merge 5 commits into
magento:2.4-developfrom
lbajsarowicz:fix/32793-graphql-has-options
Open

Add has_options and required_options to GraphQL ProductInterface (#32793)#41215
lbajsarowicz wants to merge 5 commits into
magento:2.4-developfrom
lbajsarowicz:fix/32793-graphql-has-options

Conversation

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Description (*)

Continues #33125 by @karyna-t (Atwix), which was approved by two maintainers in July 2021 and never merged. The branch fell behind 2.4-develop and conflicted on schema.graphqls; this PR carries the original commits rebased onto the current base.

has_options and required_options are columns of catalog_product_entity and are exposed through ProductInterface in REST, but not in GraphQL. The products filter and sort inputs already accept both fields, so a client can filter by them without being able to read them back. This adds both as Boolean fields on ProductInterface. No resolver is needed: the product model already carries the values from the collection load.

Changes on top of the original PR:

  • rebased on 2.4-develop, conflict in ProductInterface resolved (the fields now follow custom_attributesV2)
  • the API-functional test asserts the resolved values (true/true for the fixture product with three required custom options), not only the presence of the keys

@cpartica asked in the original review whether this belongs on CustomizableProductInterface instead. The two columns exist on every product type (bundles and configurables set required_options without custom options), and the filter and sort inputs already expose them on the generic ProductInterface, so placing the output fields on the same interface keeps the schema consistent.

Related Pull Requests

Fixed Issues (if relevant)

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

Manual testing scenarios (*)

  1. Create a simple product with a required custom option
  2. Send { products(filter: {sku: {eq: "<sku>"}}) { items { sku has_options required_options } } } to /graphql
  3. Both fields resolve to true; for a product without options both resolve to false

Questions or comments

Gates run locally on the rebased branch: PHPCS on the test file is clean, Static Tests (LiveCodeTest) result is reported in the first comment. The API-functional test needs the WebAPI build; please run it here.

The Semantic Version Checker will flag the two added interface fields as a minor GraphQL schema change (additive only).

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 templates (if applicable)
  • All automated tests passed successfully (all builds are green)

karyna-t and others added 3 commits September 4, 2026 22:09
The fixture product carries three required custom options, so both fields
must resolve to true, not merely be present in the response.
@m2-assistant

m2-assistant Bot commented Sep 4, 2026

Copy link
Copy Markdown

Hi @lbajsarowicz. 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.

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run Static Tests

The product_simple_with_custom_options fixture saves its stock item with
is_in_stock = 2 and is never picked up by the search index, so the
products query returned no items in the WebAPI build. product_with_options
is the fixture the existing customizable-options GraphQL test already
queries the same way; it also carries required options.
@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attributes has_options and required_options are not available in GraphQL

2 participants