File tree 2 files changed +8
-8
lines changed
app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest
dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 9
9
10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Framework \Exception \NoSuchEntityException ;
12
+ use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
12
13
use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
13
14
use Magento \Framework \Stdlib \ArrayManager ;
14
15
use Magento \QuoteGraphQl \Model \Cart \BuyRequest \BuyRequestDataProviderInterface ;
@@ -76,6 +77,10 @@ public function execute(array $cartItemData): array
76
77
} catch (NoSuchEntityException $ e ) {
77
78
throw new GraphQlNoSuchEntityException (__ ('Could not find specified product. ' ));
78
79
}
80
+ $ configurableProductLinks = $ parentProduct ->getExtensionAttributes ()->getConfigurableProductLinks ();
81
+ if (!in_array ($ product ->getId (), $ configurableProductLinks )) {
82
+ throw new GraphQlInputException (__ ('The child product do not belong to the parent product. ' ));
83
+ }
79
84
$ linkField = $ this ->metadataPool ->getMetadata (ProductInterface::class)->getLinkField ();
80
85
$ this ->optionCollection ->addProductId ((int )$ parentProduct ->getData ($ linkField ));
81
86
$ options = $ this ->optionCollection ->getAttributesByProductId ((int )$ parentProduct ->getData ($ linkField ));
Original file line number Diff line number Diff line change @@ -141,19 +141,14 @@ public function testAddMultipleConfigurableProductToCart()
141
141
}
142
142
143
143
/**
144
- * @magentoApiDataFixture Magento/ConfigurableProduct /_files/configurable_products .php
144
+ * @magentoApiDataFixture Magento/Catalog /_files/configurable_products_with_custom_attribute_layered_navigation .php
145
145
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
146
146
*
147
147
* @expectedException Exception
148
- * @expectedExceptionMessage You need to choose options for your item .
148
+ * @expectedExceptionMessage The child product do not belong to the parent product .
149
149
*/
150
150
public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAttributeToCart ()
151
151
{
152
- $ this ->markTestSkipped (
153
- 'Magento automatically selects the correct child product according to the super attribute
154
- https://github.com/magento/graphql-ce/issues/940 '
155
- );
156
-
157
152
$ searchResponse = $ this ->graphQlQuery ($ this ->getFetchProductQuery ('configurable_12345 ' ));
158
153
$ product = current ($ searchResponse ['products ' ]['items ' ]);
159
154
@@ -178,7 +173,7 @@ public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAt
178
173
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
179
174
*
180
175
* @expectedException Exception
181
- * @expectedExceptionMessage You need to choose options for your item .
176
+ * @expectedExceptionMessage The child product do not belong to the parent product .
182
177
*/
183
178
public function testAddVariationFromAnotherConfigurableProductWithDifferentSuperAttributeToCart ()
184
179
{
You can’t perform that action at this time.
0 commit comments