Skip to content

Commit 9532e28

Browse files
author
Prabhu Ram
committed
MC-19194: UpdateCartItems mutation does not update cart item quantity
- Reverted back commit c7d9130 and modified functional test
1 parent d525030 commit 9532e28

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private function updateItemQuantity(int $itemId, Quote $cart, float $quantity)
117117
}
118118
$cartItem->setQty($quantity);
119119
$this->validateCartItem($cartItem);
120+
$this->cartItemRepository->save($cartItem);
120121
}
121122

122123
/**

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ public function testUpdateCartItemQuantity()
7070

7171
$this->assertEquals($itemId, $item['id']);
7272
$this->assertEquals($quantity, $item['quantity']);
73+
74+
$cartQuery = $this->getCartQuery($maskedQuoteId);
75+
$response = $this->graphQlQuery($cartQuery);
76+
77+
$this->assertArrayHasKey('cart', $response);
78+
79+
$responseCart = $response['cart'];
80+
$item = current($responseCart['items']);
81+
82+
$this->assertEquals($quantity, $item['quantity']);
7383
}
7484

7585
/**
@@ -268,6 +278,26 @@ private function getQuery(string $maskedQuoteId, int $itemId, float $quantity):
268278
}
269279
}
270280
}
281+
QUERY;
282+
}
283+
284+
/**
285+
* @param string $maskedQuoteId
286+
* @return string
287+
*/
288+
private function getCartQuery(string $maskedQuoteId)
289+
{
290+
return <<<QUERY
291+
query {
292+
cart(cart_id: "{$maskedQuoteId}"){
293+
items{
294+
product{
295+
name
296+
}
297+
quantity
298+
}
299+
}
300+
}
271301
QUERY;
272302
}
273303
}

0 commit comments

Comments
 (0)