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

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

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

karyna-t
Copy link
Contributor

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

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
Copy link

m2-assistant bot commented Jun 2, 2021

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
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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
Contributor Author

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

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.

Copy link
Contributor

@eduard13 eduard13 left a comment

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
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
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
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
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
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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
Contributor Author

@magento run Integration Tests

@magento-automated-testing
Copy link

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
Contributor Author

@magento run Functional Tests EE

@magento-automated-testing
Copy link

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
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
Contributor

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

@@ -123,6 +123,8 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
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
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?

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
5 participants