Skip to content

Commit 75a4096

Browse files
committed
AC-14857: Product view enhancement
1 parent 24f4eff commit 75a4096

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/code/Magento/CatalogUrlRewriteGraphQl/Model/DataProvider/UrlRewrite/ProductDataProvider.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -11,6 +11,8 @@
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1313
use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderInterface;
14+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
15+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1416

1517
class ProductDataProvider implements EntityDataProviderInterface
1618
{
@@ -36,7 +38,7 @@ public function __construct(
3638
* @param ResolveInfo|null $info
3739
* @param int|null $storeId
3840
* @return array
39-
* @throws NoSuchEntityException
41+
* @throws GraphQlNoSuchEntityException|NoSuchEntityException
4042
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4143
*/
4244
public function getData(
@@ -47,6 +49,10 @@ public function getData(
4749
): array {
4850
$product = $this->productRepository->getById($id, false, $storeId);
4951
$result = $product->getData();
52+
53+
if ((int)$product->getStatus() !== Status::STATUS_ENABLED) {
54+
throw new GraphQlNoSuchEntityException(__('This product is disabled.'));
55+
}
5056
$result['model'] = $product;
5157
return $result;
5258
}

0 commit comments

Comments
 (0)