Skip to content

Commit 2d52b5f

Browse files
committed
ACP2E-3256: [GraphQl] [Feature Request] min/max qty allowed in shopping cart for products
1 parent c982329 commit 2d52b5f

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

app/code/Magento/CatalogInventoryGraphQl/Model/Resolver/MaxSaleQtyResolver.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\CatalogInventoryGraphQl\Model\Resolver;
99

10+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1011
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Query\ResolverInterface;
@@ -37,10 +38,10 @@ public function __construct(
3738
*/
3839
public function resolve(
3940
Field $field,
40-
$context,
41+
ContextInterface $context,
4142
ResolveInfo $info,
42-
array $value = null,
43-
array $args = null
43+
?array $value,
44+
?array $args
4445
) {
4546
$stockItem = $this->stockItemService->getStockItem($value['model']);
4647
return $stockItem ? $stockItem->getMaxSaleQty() : null;

app/code/Magento/CatalogInventoryGraphQl/Model/Resolver/MinSaleQtyResolver.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\CatalogInventoryGraphQl\Model\Resolver;
99

10+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
1011
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Query\ResolverInterface;
@@ -37,10 +38,10 @@ public function __construct(
3738
*/
3839
public function resolve(
3940
Field $field,
40-
$context,
41+
ContextInterface $context,
4142
ResolveInfo $info,
42-
array $value = null,
43-
array $args = null
43+
?array $value,
44+
?array $args
4445
) {
4546
$stockItem = $this->stockItemService->getStockItem($value['model']);
4647
return $stockItem ? $stockItem->getMinSaleQty() : null;

app/code/Magento/CatalogInventoryGraphQl/Model/StockItemService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Model\Product;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\CatalogInventory\Model\StockRegistry;
14+
use Magento\CatalogInventory\Model\Stock\Item;
1415

1516
/**
1617
* Service to provide stock item for given product
@@ -48,9 +49,9 @@ public function __construct(
4849
* Returns stock item if the product is available
4950
*
5051
* @param Product|null $product
51-
* @return mixed
52+
* @return Item
5253
*/
53-
public function getStockItem(Product $product = null)
54+
public function getStockItem(?Product $product)
5455
{
5556
if (!isset($product)) {
5657
throw new LocalizedException(__('"model" value should be specified'));

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogInventory/MinMaxSaleQtyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);

0 commit comments

Comments
 (0)