Skip to content

Commit 9a7dd6d

Browse files
committed
MC-29839: [GraphQL] Configurable Options id/code Type Mismatch
1 parent 0423eae commit 9a7dd6d

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

app/code/Magento/ConfigurableProductGraphQl/Model/Options/Collection.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\Product;
12-
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory;
12+
use Magento\Catalog\Model\ProductFactory;
13+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute;
1314
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection
1415
as AttributeCollection;
15-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute;
16-
use Magento\Catalog\Model\ProductFactory;
16+
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory;
1717
use Magento\Framework\EntityManager\MetadataPool;
1818

1919
/**
@@ -121,6 +121,8 @@ private function fetch() : array
121121
$attributeData = $attribute->getData();
122122
$this->attributeMap[$productId][$attribute->getId()] = $attribute->getData();
123123
$this->attributeMap[$productId][$attribute->getId()]['id'] = $attribute->getId();
124+
$this->attributeMap[$productId][$attribute->getId()]['attribute_id_v2']
125+
= $attribute->getProductAttribute()->getAttributeId();
124126
$this->attributeMap[$productId][$attribute->getId()]['attribute_code']
125127
= $attribute->getProductAttribute()->getAttributeCode();
126128
$this->attributeMap[$productId][$attribute->getId()]['values'] = $attributeData['options'];

app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ type ConfigurableAttributeOption @doc(description: "ConfigurableAttributeOption
2222

2323
type ConfigurableProductOptions @doc(description: "ConfigurableProductOptions defines configurable attributes for the specified product") {
2424
id: Int @doc(description: "The configurable option ID number assigned by the system")
25-
attribute_id: String @doc(description: "The ID assigned to the attribute")
25+
attribute_id: String @deprecated(reason: "Use attribute_id_v2 instead") @doc(description: "The ID assigned to the attribute")
26+
attribute_id_v2: Int @doc(description: "The ID assigned to the attribute")
2627
attribute_code: String @doc(description: "A string that identifies the attribute")
2728
label: String @doc(description: "A string that describes the configurable product option, which is displayed on the UI")
2829
position: Int @doc(description: "A number that indicates the order in which the attribute is displayed")

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/ConfigurableProductViewTest.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function testQueryConfigurableProductLinks()
9696
configurable_options {
9797
id
9898
attribute_id
99+
attribute_id_v2
99100
label
100101
position
101102
use_default
@@ -335,23 +336,15 @@ private function assertConfigurableVariants($actualResponse)
335336
$mediaGalleryEntries,
336337
"Precondition failed since there are incorrect number of media gallery entries"
337338
);
338-
$this->assertIsArray($actualResponse['variants']
339-
[$variantKey]
340-
['product']
341-
['media_gallery_entries']
342-
343-
);
339+
$this->assertIsArray($actualResponse['variants'][$variantKey]['product']['media_gallery_entries']);
344340
$this->assertCount(
345341
1,
346342
$actualResponse['variants'][$variantKey]['product']['media_gallery_entries'],
347343
"there must be 1 record in the media gallery"
348344
);
349345
$mediaGalleryEntry = $mediaGalleryEntries[0];
350346
$this->assertResponseFields(
351-
$actualResponse['variants']
352-
[$variantKey]
353-
['product']
354-
['media_gallery_entries'][0],
347+
$actualResponse['variants'][$variantKey]['product']['media_gallery_entries'][0],
355348
[
356349
'disabled' => (bool)$mediaGalleryEntry->isDisabled(),
357350
'file' => $mediaGalleryEntry->getFile(),
@@ -363,12 +356,7 @@ private function assertConfigurableVariants($actualResponse)
363356
);
364357
$videoContent = $mediaGalleryEntry->getExtensionAttributes()->getVideoContent();
365358
$this->assertResponseFields(
366-
$actualResponse['variants']
367-
[$variantKey]
368-
['product']
369-
['media_gallery_entries']
370-
[0]
371-
['video_content'],
359+
$actualResponse['variants'][$variantKey]['product']['media_gallery_entries'][0]['video_content'],
372360
[
373361
'media_type' =>$videoContent->getMediaType(),
374362
'video_description' => $videoContent->getVideoDescription(),
@@ -454,6 +442,11 @@ private function assertConfigurableProductOptions($actualResponse)
454442
$actualResponse['configurable_options'][0]['attribute_id'],
455443
$configurableAttributeOption['attribute_id']
456444
);
445+
$this->assertEquals(
446+
$actualResponse['configurable_options'][0]['attribute_id_v2'],
447+
$configurableAttributeOption['attribute_id']
448+
);
449+
$this->assertIsInt($actualResponse['configurable_options'][0]['attribute_id_v2']);
457450
$this->assertEquals(
458451
$actualResponse['configurable_options'][0]['label'],
459452
$configurableAttributeOption['label']

0 commit comments

Comments
 (0)