Skip to content

Commit 81daba8

Browse files
XxXgeoXxXnaydav
authored andcommitted
Cannot return null for non-nullable field SelectedCustomizableOptionValue.sort_order and Call to a member function getPriceType() on null
1 parent 93a8162 commit 81daba8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1616
use Magento\Framework\Stdlib\ArrayManager;
1717
use Magento\Quote\Model\Quote;
18+
use phpDocumentor\Reflection\Types\Mixed_;
1819

1920
/**
2021
* Add simple product to cart
@@ -140,7 +141,9 @@ private function extractCustomizableOptions(array $cartItemData): array
140141

141142
$customizableOptionsData = [];
142143
foreach ($customizableOptions as $customizableOption) {
143-
$customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
144+
$customizableOptionsData[$customizableOption['id']] = $this->convertCustomOptions(
145+
$customizableOption['value']
146+
);
144147
}
145148
return $customizableOptionsData;
146149
}
@@ -161,4 +164,17 @@ private function createBuyRequest(float $quantity, array $customOptions): DataOb
161164
],
162165
]);
163166
}
167+
168+
/**
169+
* @param string $value
170+
* @return string|array
171+
*/
172+
private function convertCustomOptions(string $value)
173+
{
174+
if (substr($value, 0, 1) === "[" ||
175+
substr($value, strlen($value) - 1, 1) === "]") {
176+
return explode(',', substr($value, 1, -1));
177+
}
178+
return $value;
179+
}
164180
}

app/code/Magento/QuoteGraphQl/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<item name="area" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Text</item>
2727
<item name="drop_down" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Dropdown</item>
2828
<item name="radio" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Dropdown</item>
29-
<item name="checkbox" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Dropdown</item>
29+
<item name="checkbox" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Multiple</item>
3030
<item name="multiple" xsi:type="string">Magento\QuoteGraphQl\Model\CartItem\DataProvider\CustomizableOptionValue\Multiple</item>
3131
</argument>
3232
</arguments>

0 commit comments

Comments
 (0)