Skip to content

Commit 61c33ec

Browse files
committed
MC-43189: [Graphql] Swatch Configurable option can be added to cart on any website
1 parent 9264a46 commit 61c33ec

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public function execute(array $cartItemData): array
9292
} catch (NoSuchEntityException $e) {
9393
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
9494
}
95+
if (!in_array($cart->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
96+
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
97+
}
9598

9699
$this->checkProductStock($sku, (float) $qty, (int) $cart->getStore()->getWebsiteId());
97100

app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public function execute(array $cartItemData): array
4040

4141
if (isset($cartItemData['data']) && isset($cartItemData['data']['sku'])) {
4242
$sku = $cartItemData['data']['sku'];
43-
$product = $this->productRepository->get($sku);
43+
try {
44+
$product = $this->productRepository->get($sku);
45+
} catch (NoSuchEntityException $e) {
46+
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
47+
}
4448

4549
if ($product->getLinksPurchasedSeparately() && isset($cartItemData['downloadable_product_links'])) {
4650
$downloadableLinks = $cartItemData['downloadable_product_links'];

0 commit comments

Comments
 (0)