Skip to content

Commit 3f0b7ae

Browse files
committed
ACP2E-3885: is_available attribute in CartItemInterface returns false even when salable stock is high
1 parent f5132d5 commit 3f0b7ae

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

app/code/Magento/QuoteGraphQl/Model/CartItem/ProductStock.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public function __construct(
6363
*/
6464
public function isProductAvailable(Item $cartItem): bool
6565
{
66-
if (!$cartItem->getQtyToAdd()) {
67-
return false;
68-
}
6966
$requestedQty = $cartItem->getQtyToAdd() ?? $cartItem->getQty();
7067
$previousQty = $cartItem->getPreviousQty() ?? 0;
7168

app/code/Magento/QuoteGraphQl/Test/Unit/Model/CartItem/ProductStockTest.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,6 @@ protected function setUp(): void
8282
);
8383
}
8484

85-
/**
86-
* Test isProductAvailable() without quantity to add
87-
*/
88-
public function testIsProductAvailableWithoutQtyToAdd(): void
89-
{
90-
$cartItemMock = $this->getMockBuilder(Item::class)
91-
->addMethods(['getQtyToAdd'])
92-
->disableOriginalConstructor()
93-
->getMock();
94-
$cartItemMock->expects($this->once())
95-
->method('getQtyToAdd')
96-
->willReturn(null);
97-
$this->assertFalse($this->productStock->isProductAvailable($cartItemMock));
98-
}
99-
10085
/**
10186
* Test isProductAvailable() for a simple product with sufficient stock
10287
*/
@@ -113,7 +98,7 @@ public function testIsProductAvailableForSimpleProductWithStock(): void
11398
->disableOriginalConstructor()
11499
->addMethods(['getHasError'])
115100
->getMockForAbstractClass();
116-
$cartItemMock->expects($this->exactly(2))
101+
$cartItemMock->expects($this->once())
117102
->method('getQtyToAdd')
118103
->willReturn(2);
119104
$cartItemMock->expects($this->once())
@@ -164,7 +149,7 @@ public function testIsProductAvailableForSimpleProductWithoutStock(): void
164149
->disableOriginalConstructor()
165150
->addMethods(['getHasError'])
166151
->getMockForAbstractClass();
167-
$cartItemMock->expects($this->exactly(2))
152+
$cartItemMock->expects($this->once())
168153
->method('getQtyToAdd')
169154
->willReturn(5);
170155
$cartItemMock->expects($this->once())

0 commit comments

Comments
 (0)