Skip to content

Commit 0be134c

Browse files
committed
Merge branch 'MC-42970' of https://github.com/magento-l3/magento2ce into PR-2021-08-18
2 parents 7e364fd + 7ae0429 commit 0be134c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public function execute(Quote $cart, array $cartItemData): void
6060
} catch (NoSuchEntityException $e) {
6161
throw new GraphQlNoSuchEntityException(__('Could not find a product with SKU "%sku"', ['sku' => $sku]));
6262
}
63+
if (!in_array($cart->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
64+
throw new GraphQlNoSuchEntityException(__('Could not find a product with SKU "%sku"', ['sku' => $sku]));
65+
}
6366

6467
try {
6568
$result = $cart->addProduct($product, $this->buyRequestBuilder->build($cartItemData));

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,26 @@ public function testAddNonExistentConfigurableProductParentToCart()
249249
$this->graphQlMutation($query);
250250
}
251251

252+
/**
253+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php
254+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
255+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote_not_default_website.php
256+
*/
257+
public function testAddConfigurableProductNotAssignedToWebsite()
258+
{
259+
$this->expectException(\Exception::class);
260+
$this->expectExceptionMessage('Could not find a product with SKU "configurable"');
261+
262+
$reservedOrderId = 'test_order_2';
263+
$parentSku = 'configurable';
264+
$sku = 'simple_20';
265+
$headerMap = ['Store' => 'fixture_second_store'];
266+
267+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
268+
$query = $this->getQuery($maskedQuoteId, $parentSku, $sku, 1);
269+
$this->graphQlMutation($query, [], '', $headerMap);
270+
}
271+
252272
/**
253273
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php
254274
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php

0 commit comments

Comments
 (0)