Skip to content

Commit c96f7a4

Browse files
author
Cody Nguyen
committed
Return 0 instead of null when stock is zero
1 parent d770920 commit c96f7a4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function getOnlyXLeftQty(ProductInterface $product): ?float
8686

8787
$stockLeft = $stockCurrentQty - $stockItem->getMinQty();
8888

89-
if ($stockLeft > 0 && $stockLeft <= $thresholdQty) {
89+
if ($stockCurrentQty >= 0 && $stockLeft <= $thresholdQty) {
9090
return (float)$stockCurrentQty;
9191
}
9292

app/code/Magento/CatalogInventoryGraphQl/Test/Unit/Model/Resolver/OnlyXLeftInStockResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function testResolveOutStock()
169169
$this->scopeConfigMock->method('getValue')->willReturn($thresholdQty);
170170

171171
$this->assertEquals(
172-
null,
172+
0,
173173
$this->resolver->resolve(
174174
$this->fieldMock,
175175
$this->contextMock,

0 commit comments

Comments
 (0)