File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest
dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 99
1010use Magento \Catalog \Api \Data \ProductInterface ;
1111use Magento \Framework \Exception \NoSuchEntityException ;
12+ use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
1213use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
1314use Magento \Framework \Stdlib \ArrayManager ;
1415use Magento \QuoteGraphQl \Model \Cart \BuyRequest \BuyRequestDataProviderInterface ;
@@ -76,6 +77,10 @@ public function execute(array $cartItemData): array
7677 } catch (NoSuchEntityException $ e ) {
7778 throw new GraphQlNoSuchEntityException (__ ('Could not find specified product. ' ));
7879 }
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+ }
7984 $ linkField = $ this ->metadataPool ->getMetadata (ProductInterface::class)->getLinkField ();
8085 $ this ->optionCollection ->addProductId ((int )$ parentProduct ->getData ($ linkField ));
8186 $ 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()
141141 }
142142
143143 /**
144- * @magentoApiDataFixture Magento/ConfigurableProduct /_files/configurable_products .php
144+ * @magentoApiDataFixture Magento/Catalog /_files/configurable_products_with_custom_attribute_layered_navigation .php
145145 * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
146146 *
147147 * @expectedException Exception
148- * @expectedExceptionMessage You need to choose options for your item .
148+ * @expectedExceptionMessage The child product do not belong to the parent product .
149149 */
150150 public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAttributeToCart ()
151151 {
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-
157152 $ searchResponse = $ this ->graphQlQuery ($ this ->getFetchProductQuery ('configurable_12345 ' ));
158153 $ product = current ($ searchResponse ['products ' ]['items ' ]);
159154
@@ -178,7 +173,7 @@ public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAt
178173 * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
179174 *
180175 * @expectedException Exception
181- * @expectedExceptionMessage You need to choose options for your item .
176+ * @expectedExceptionMessage The child product do not belong to the parent product .
182177 */
183178 public function testAddVariationFromAnotherConfigurableProductWithDifferentSuperAttributeToCart ()
184179 {
You can’t perform that action at this time.
0 commit comments