Skip to content

Commit d3734f8

Browse files
committed
magento/graphql-ce#622: No possibility to update customizable_options in updateCartItems mutation
- code style + minor fixes
1 parent 1cf357b commit d3734f8

File tree

5 files changed

+22
-48
lines changed

5 files changed

+22
-48
lines changed

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,4 @@ private function extractQuantity(array $cartItemData): float
114114
}
115115
return $quantity;
116116
}
117-
118-
/**
119-
* Extract Customizable Options from cart item data
120-
*
121-
* @param array $cartItemData
122-
* @return array
123-
*/
124-
private function extractCustomizableOptions(array $cartItemData): array
125-
{
126-
if (!isset($cartItemData['customizable_options']) || empty($cartItemData['customizable_options'])) {
127-
return [];
128-
}
129-
130-
$customizableOptionsData = [];
131-
foreach ($cartItemData['customizable_options'] as $customizableOption) {
132-
if (isset($customizableOption['value_string'])) {
133-
$customizableOptionsData[$customizableOption['id']] = $this->convertCustomOptionValue(
134-
$customizableOption['value_string']
135-
);
136-
}
137-
}
138-
return $customizableOptionsData;
139-
}
140117
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ public function execute(float $qty, array $customizableOptionsData): DataObject
4747
}
4848
}
4949

50-
return $this->dataObjectFactory->create([
51-
'data' => [
52-
'qty' => $qty,
53-
'options' => $customizableOptions,
54-
],
55-
]);
50+
return $this->dataObjectFactory->create(
51+
[
52+
'data' => [
53+
'qty' => $qty,
54+
'options' => $customizableOptions,
55+
],
56+
]
57+
);
5658
}
5759

5860
/**

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
/**
2020
* Update cart item
21-
*
2221
*/
2322
class UpdateCartItem
2423
{
@@ -86,18 +85,13 @@ public function execute(Quote $cart, int $cartItemId, float $quantity, array $cu
8685
);
8786
}
8887

89-
if (is_string($result)) {
90-
throw new GraphQlInputException(__(
91-
'Could not update cart item: %message',
92-
['message' => $result]
93-
));
94-
}
95-
9688
if ($result->getHasError()) {
97-
throw new GraphQlInputException(__(
98-
'Could not update cart item: %message',
99-
['message' => $result->getMessage(true)]
100-
));
89+
throw new GraphQlInputException(
90+
__(
91+
'Could not update cart item: %message',
92+
['message' => $result->getMessage()]
93+
)
94+
);
10195
}
10296

10397
$this->quoteRepository->save($cart);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ private function getQuoteItemIdBySku(string $sku): int
240240
return (int)$quoteItem->getId();
241241
}
242242

243-
244243
/**
245244
* Generate an array with test values for customizable options
246245
* based on the option type

dev/tests/integration/testsuite/Magento/GraphQl/Quote/_files/add_simple_product_with_options.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@
3838
$cartItemCustomOptions[$productOption->getId()] = 'initial value';
3939
}
4040

41-
$request = $dataObjectFactory->create([
42-
'data' => [
43-
'qty' => 1.0,
44-
'options' => $cartItemCustomOptions,
45-
],
46-
]);
41+
$request = $dataObjectFactory->create(
42+
[
43+
'data' => [
44+
'qty' => 1.0,
45+
'options' => $cartItemCustomOptions,
46+
],
47+
]
48+
);
4749

4850
$quote = $quoteFactory->create();
4951
$quoteResource->load($quote, 'test_quote', 'reserved_order_id');

0 commit comments

Comments
 (0)