-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Issue 32793 Add has_options and required_options to grapql Product Interface #33125
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
base: 2.4-develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||||||
<?php | ||||||||||
/** | ||||||||||
* Copyright © Magento, Inc. All rights reserved. | ||||||||||
* See COPYING.txt for license details. | ||||||||||
*/ | ||||||||||
declare(strict_types=1); | ||||||||||
|
||||||||||
namespace Magento\GraphQl\Catalog; | ||||||||||
|
||||||||||
use Magento\TestFramework\TestCase\GraphQlAbstract; | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a class description |
||||||||||
class ProductHasOptionsTest extends GraphQlAbstract | ||||||||||
{ | ||||||||||
/** | ||||||||||
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_custom_options.php | ||||||||||
*/ | ||||||||||
public function testHasOptionsAndRequiredOptionsAttribute() | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
{ | ||||||||||
$productSku = 'simple_with_custom_options'; | ||||||||||
$query = <<<QUERY | ||||||||||
{ | ||||||||||
products(filter: {sku: {eq: "{$productSku}"}}) { | ||||||||||
items { | ||||||||||
sku | ||||||||||
has_options | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
required_options | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
QUERY; | ||||||||||
$response = $this->graphQlQuery($query); | ||||||||||
|
||||||||||
self::assertArrayHasKey('has_options', $response['products']['items'][0]); | ||||||||||
self::assertArrayHasKey('required_options', $response['products']['items'][0]); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
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?