Skip to content

Commit bf4f0e7

Browse files
authored
ENGCOM-4442: Extended product customizable options coverage #414
2 parents 3a4ba66 + b2e34b1 commit bf4f0e7

File tree

5 files changed

+97
-2
lines changed

5 files changed

+97
-2
lines changed

app/code/Magento/CatalogGraphQl/etc/graphql/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
</item>
3939
<item name="customizable_options" xsi:type="array">
4040
<item name="field" xsi:type="string">CustomizableFieldOption</item>
41+
<item name="date" xsi:type="string">CustomizableDateOption</item>
4142
<item name="date_time" xsi:type="string">CustomizableDateOption</item>
43+
<item name="time" xsi:type="string">CustomizableDateOption</item>
4244
<item name="file" xsi:type="string">CustomizableFileOption</item>
4345
<item name="area" xsi:type="string">CustomizableAreaOption</item>
4446
<item name="drop_down" xsi:type="string">CustomizableDropDownOption</item>
47+
<item name="multiple" xsi:type="string">CustomizableMultipleOption</item>
4548
<item name="radio" xsi:type="string">CustomizableRadioOption</item>
49+
<item name="checkbox" xsi:type="string">CustomizableCheckboxOption</item>
4650
</item>
4751
</argument>
4852
</arguments>

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,19 @@ type CustomizableDropDownValue @doc(description: "CustomizableDropDownValue defi
323323
sort_order: Int @doc(description: "The order in which the option is displayed")
324324
}
325325

326+
type CustomizableMultipleOption implements CustomizableOptionInterface @doc(description: "CustomizableMultipleOption contains information about a multiselect that is defined as part of a customizable option") {
327+
value: [CustomizableMultipleValue] @doc(description: "An array that defines the set of options for a multiselect")
328+
}
329+
330+
type CustomizableMultipleValue @doc(description: "CustomizableMultipleValue defines the price and sku of a product whose page contains a customized multiselect") {
331+
option_type_id: Int @doc(description: "The ID assigned to the value")
332+
price: Float @doc(description: "The price assigned to this option")
333+
price_type: PriceTypeEnum @doc(description: "FIXED, PERCENT, or DYNAMIC")
334+
sku: String @doc(description: "The Stock Keeping Unit for this option")
335+
title: String @doc(description: "The display name for this option")
336+
sort_order: Int @doc(description: "The order in which the option is displayed")
337+
}
338+
326339
type CustomizableFieldOption implements CustomizableOptionInterface @doc(description: "CustomizableFieldOption contains information about a text field that is defined as part of a customizable option") {
327340
value: CustomizableFieldValue @doc(description: "An object that defines a text field")
328341
product_sku: String @doc(description: "The Stock Keeping Unit of the base product")
@@ -407,6 +420,19 @@ type CustomizableRadioValue @doc(description: "CustomizableRadioValue defines t
407420
sort_order: Int @doc(description: "The order in which the radio button is displayed")
408421
}
409422

423+
type CustomizableCheckboxOption implements CustomizableOptionInterface @doc(description: "CustomizableCheckbbixOption contains information about a set of checkbox values that are defined as part of a customizable option") {
424+
value: [CustomizableCheckboxValue] @doc(description: "An array that defines a set of checkbox values")
425+
}
426+
427+
type CustomizableCheckboxValue @doc(description: "CustomizableCheckboxValue defines the price and sku of a product whose page contains a customized set of checkbox values") {
428+
option_type_id: Int @doc(description: "The ID assigned to the value")
429+
price: Float @doc(description: "The price assigned to this option")
430+
price_type: PriceTypeEnum @doc(description: "FIXED, PERCENT, or DYNAMIC")
431+
sku: String @doc(description: "The Stock Keeping Unit for this option")
432+
title: String @doc(description: "The display name for this option")
433+
sort_order: Int @doc(description: "The order in which the checkbox value is displayed")
434+
}
435+
410436
type VirtualProduct implements ProductInterface, CustomizableProductInterface @doc(description: "A virtual product is non-tangible product that does not require shipping and is not kept in inventory") {
411437
}
412438

app/code/Magento/QuoteGraphQl/Model/CartItem/DataProvider/CustomizableOptionValue/Text.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function getData(
4242
): array {
4343
/** @var TextOptionType $optionTypeRenderer */
4444
$optionTypeRenderer = $option->groupFactory($option->getType());
45+
$optionTypeRenderer->setOption($option);
4546
$priceValueUnits = $this->priceUnitLabel->getData($option->getPriceType());
4647

4748
$selectedOptionValueData = [

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductViewTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,26 @@ public function testQueryAllFieldsSimpleProduct()
137137
sort_order
138138
}
139139
}
140+
... on CustomizableCheckboxOption {
141+
checkbox_option: value {
142+
option_type_id
143+
sku
144+
price
145+
price_type
146+
title
147+
sort_order
148+
}
149+
}
150+
... on CustomizableMultipleOption {
151+
multiple_option: value {
152+
option_type_id
153+
sku
154+
price
155+
price_type
156+
title
157+
sort_order
158+
}
159+
}
140160
...on CustomizableFileOption {
141161
product_sku
142162
file_option: value {
@@ -736,7 +756,7 @@ private function assertOptions($product, $actualResponse)
736756
$values = $option->getValues();
737757
/** @var \Magento\Catalog\Model\Product\Option\Value $value */
738758
$value = current($values);
739-
$findValueKeyName = $option->getType() === 'radio' ? 'radio_option' : 'drop_down_option';
759+
$findValueKeyName = $option->getType() . '_option';
740760
if ($value->getTitle() === $optionsArray[$findValueKeyName][0]['title']) {
741761
$match = true;
742762
}
@@ -756,7 +776,7 @@ private function assertOptions($product, $actualResponse)
756776
];
757777

758778
if (!empty($option->getValues())) {
759-
$valueKeyName = $option->getType() === 'radio' ? 'radio_option' : 'drop_down_option';
779+
$valueKeyName = $option->getType() . '_option';
760780
$value = current($optionsArray[$valueKeyName]);
761781
/** @var \Magento\Catalog\Model\Product\Option\Value $productValue */
762782
$productValue = current($option->getValues());

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_full_option_set.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,50 @@
187187
'price_type' => 'percent',
188188
'sku' => 'sku2',
189189
'max_characters' => 20,
190+
],
191+
[
192+
'title' => 'multiple option',
193+
'type' => 'multiple',
194+
'is_require' => true,
195+
'sort_order' => 7,
196+
'values' => [
197+
[
198+
'title' => 'multiple option 1',
199+
'price' => 10,
200+
'price_type' => 'fixed',
201+
'sku' => 'multiple option 1 sku',
202+
'sort_order' => 1,
203+
],
204+
[
205+
'title' => 'multiple option 2',
206+
'price' => 20,
207+
'price_type' => 'fixed',
208+
'sku' => 'multiple option 2 sku',
209+
'sort_order' => 2,
210+
],
211+
],
212+
],
213+
[
214+
'title' => 'checkbox option',
215+
'type' => 'checkbox',
216+
'is_require' => true,
217+
'sort_order' => 6,
218+
'values' => [
219+
[
220+
'title' => 'checkbox option 1',
221+
'price' => 10,
222+
'price_type' => 'fixed',
223+
'sku' => 'checkbox option 1 sku',
224+
'sort_order' => 1,
225+
],
226+
[
227+
'title' => 'checkbox option 2',
228+
'price' => 20,
229+
'price_type' => 'fixed',
230+
'sku' => 'checkbox option 2 sku',
231+
'sort_order' => 2,
232+
],
233+
],
190234
]
191235
];
192236

0 commit comments

Comments
 (0)