-
Notifications
You must be signed in to change notification settings - Fork 154
Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order and Call to a member function getPriceType() on n #525
Conversation
@@ -15,6 +15,7 @@ | |||
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; | |||
use Magento\Framework\Stdlib\ArrayManager; | |||
use Magento\Quote\Model\Quote; | |||
use phpDocumentor\Reflection\Types\Mixed_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove the redundant dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -135,7 +136,9 @@ private function extractCustomizableOptions(array $cartItemData): array | |||
|
|||
$customizableOptionsData = []; | |||
foreach ($customizableOptions as $customizableOption) { | |||
$customizableOptionsData[$customizableOption['id']] = $customizableOption['value']; | |||
$customizableOptionsData[$customizableOption['id']] = $this->convertCustomOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, cover functionality with API-functional test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests were added
*/ | ||
private function convertCustomOptions(string $value) | ||
{ | ||
if (substr($value, 0, 1) === "[" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need OR
or AND
condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. We need AND condition. PR was updated
Hi, @XxXgeoXxX. Feel free to write me in Slack if I can be useful for you during work on this issue. |
When I have this product prod_opt.zip and create the empty cart as a Customer and add this product to cart by querying mutation addSimpleProductsToCart(
$cart_id: String!
$qty: Float!
$sku: String!
) {
addSimpleProductsToCart(
input: {
cart_id: $cart_id
cartItems: {
customizable_options: [
{
id: 1
value: "[1]"
}
{
id: 2
value: "4"
}
{
id: 3
value: "7"
}
{
id: 4
value: "[10]"
}
]
data: {
qty: $qty
sku: $sku
}
}
}
) {
cart {
items {
id
qty
product {
sku
stock_status
}
... on SimpleCartItem {
customizable_options {
id
is_required
label
type
values {
id
label
price {
value
}
sort_order
}
}
}
}
}
}
} with variables {
"cart_id": "4nsy2q2ldOGv2hcJqjnRUhH1Ub7r9TOt",
"qty": 1,
"sku": "simple-product-with-options"
} I get this problem: {
"errors": [
{
"debugMessage": "Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order.",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 23,
"column": 15
}
],
"path": [
"addSimpleProductsToCart",
"cart",
"items",
0,
"customizable_options",
0,
"values",
0,
"sort_order"
]
},
{
"debugMessage": "Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order.",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 23,
"column": 15
}
],
"path": [
"addSimpleProductsToCart",
"cart",
"items",
0,
"customizable_options",
1,
"values",
0,
"sort_order"
]
},
{
"debugMessage": "Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order.",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 23,
"column": 15
}
],
"path": [
"addSimpleProductsToCart",
"cart",
"items",
0,
"customizable_options",
2,
"values",
0,
"sort_order"
]
},
{
"debugMessage": "Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order.",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 23,
"column": 15
}
],
"path": [
"addSimpleProductsToCart",
"cart",
"items",
0,
"customizable_options",
3,
"values",
0,
"sort_order"
]
}
],
"data": {
"addSimpleProductsToCart": {
"cart": {
"items": [
{
"id": "301",
"qty": 2,
"product": {
"sku": "simple-product-with-options",
"stock_status": "IN_STOCK"
},
"customizable_options": [
{
"id": 1,
"is_required": 1,
"label": "opt1",
"type": "checkbox",
"values": [
null
]
},
{
"id": 2,
"is_required": 1,
"label": "opt2",
"type": "radio",
"values": [
null
]
},
{
"id": 3,
"is_required": 1,
"label": "opt3",
"type": "drop_down",
"values": [
null
]
},
{
"id": 4,
"is_required": 1,
"label": "opt4",
"type": "multiple",
"values": [
null
]
}
]
}
]
}
}
}
} |
@XxXgeoXxX, please apply updates from mainline. |
@TomashKhamlai I merged mainline, please, continue testing the issue |
Great point! It was a mistake in the initial scheme. |
…alue.sort_order and Call to a member function getPriceType() on null
…alue.sort_order and Call to a member function getPriceType() on null
…alue.sort_order and Call to a member function getPriceType() on null
…alue.sort_order and Call to a member function getPriceType() on null
…izableOptionValue.sort_order and Call to a member function getPriceType() on null
…izableOptionValue.sort_order and Call to a member function getPriceType() on null
…izableOptionValue.sort_order and Call to a member function getPriceType() on null
Hi @XxXgeoXxX, thank you for your contribution! |
Description (*)
Description #474
Manual testing scenarios (*)
Generate Customer token
Create an empty cart as Registered Customer from GraphQL Client
Perform mutation from the description
Note: Magento get custom options from frontend like mixed data [id=>string, id=>array]. That's why in graphQl query we catch error for multidimensional data(Example: checkbox).
Also 'sort_order' doesn't exist on values level.
Example for multiple data:
Contribution checklist (*)