Skip to content

Commit 490fdf9

Browse files
committed
Merge branch 'graphql-api-enhancements' of github.com:magento-lynx/magento2ce into graphql-api-enhancements
2 parents 0c80bc4 + 1a78cb6 commit 490fdf9

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\QuoteGraphQl\Model\Resolver;
18+
19+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
20+
use Magento\Framework\GraphQl\Config\Element\Field;
21+
use Magento\Framework\GraphQl\Query\ResolverInterface;
22+
23+
/**
24+
* Resolver for the product_image store config settings
25+
*/
26+
class StoreConfig implements ResolverInterface
27+
{
28+
/**
29+
* @inheritdoc
30+
*/
31+
public function resolve(
32+
Field $field,
33+
$context,
34+
ResolveInfo $info,
35+
array $value = null,
36+
array $args = null
37+
) {
38+
return (strtoupper($value[$field->getName()]));
39+
}
40+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
<item name="minicart_display" xsi:type="string">checkout/sidebar/display</item>
7171
<item name="minicart_max_items" xsi:type="string">checkout/sidebar/max_items_display_count</item>
7272
<item name="cart_expires_in_days" xsi:type="string">checkout/cart/delete_quote_after</item>
73+
<item name="grouped_product_image" xsi:type="string">checkout/cart/grouped_product_image</item>
74+
<item name="configurable_product_image" xsi:type="string">checkout/cart/configurable_product_image</item>
7375
</argument>
7476
</arguments>
7577
</type>

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,20 @@ enum PlaceOrderErrorCodes {
509509
}
510510

511511
type StoreConfig {
512-
is_guest_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/guest_checkout")
513-
is_one_page_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/onepage_checkout_enabled")
514-
max_items_in_order_summary: Int @doc(description: "Extended Config Data - checkout/options/max_items_display_count")
515-
cart_summary_display_quantity: Int @doc(description: "Extended Config Data - checkout/cart_link/use_qty")
516-
minicart_display: Boolean @doc(description: "Extended Config Data - checkout/sidebar/display")
517-
minicart_max_items: Int @doc(description: "Extended Config Data - checkout/sidebar/count")
518-
cart_expires_in_days: Int @doc(description: "Extended Config Data - checkout/cart/delete_quote_after")
512+
is_guest_checkout_enabled: Boolean @doc(description: "checkout/options/guest_checkout: whether the guest checkout is enabled or not.")
513+
is_one_page_checkout_enabled: Boolean @doc(description: "checkout/options/onepage_checkout_enabled: whether the one page checkout is enabled or not")
514+
max_items_in_order_summary: Int @doc(description: "checkout/options/max_items_display_count: maximum number of items to display in order summary.")
515+
cart_summary_display_quantity: Int @doc(description: "checkout/cart_link/use_qty: what to show in the display cart summary, number of items or item quantities.")
516+
minicart_display: Boolean @doc(description: "checkout/sidebar/display: whether to display the minicart or not.")
517+
minicart_max_items: Int @doc(description: "checkout/sidebar/count: maximum number of items to show in minicart.")
518+
cart_expires_in_days: Int @doc(description: "checkout/cart/delete_quote_after: quote lifetime in days.")
519+
grouped_product_image: ProductImageThumbnail! @doc(description: "checkout/cart/grouped_product_image: which image to use for grouped products.") @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\StoreConfig")
520+
configurable_product_image: ProductImageThumbnail! @doc(description: "checkout/cart/configurable_product_image: which image to use for configurable products.") @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\StoreConfig")
521+
}
522+
523+
enum ProductImageThumbnail {
524+
ITSELF @doc(description: "Use thumbnail of product as image.")
525+
PARENT @doc(description: "Use thumbnail of product's parent as image.")
519526
}
520527

521528
input EstimateTotalsInput {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class StoreConfigResolverTest extends GraphQlAbstract
4040
ScopeInterface::SCOPE_STORE,
4141
'default'
4242
),
43+
ConfigFixture('checkout/cart/grouped_product_image', 'parent', ScopeInterface::SCOPE_STORE, 'default'),
44+
ConfigFixture('checkout/cart/configurable_product_image', 'itself', ScopeInterface::SCOPE_STORE, 'default')
4345
]
4446
public function testGetStoreConfig(): void
4547
{
@@ -53,7 +55,9 @@ public function testGetStoreConfig(): void
5355
cart_summary_display_quantity,
5456
minicart_display,
5557
minicart_max_items,
56-
cart_expires_in_days
58+
cart_expires_in_days,
59+
grouped_product_image,
60+
configurable_product_image
5761
}
5862
}
5963
QUERY;
@@ -77,5 +81,7 @@ private function validateStoreConfig(
7781
$this->assertTrue($responseConfig['minicart_display']);
7882
$this->assertEquals(self::MINICART_MAX_ITEMS, $responseConfig['minicart_max_items']);
7983
$this->assertEquals(self::CART_EXPIRES_IN_DAYS, $responseConfig['cart_expires_in_days']);
84+
$this->assertEquals('PARENT', $responseConfig['grouped_product_image']);
85+
$this->assertEquals('ITSELF', $responseConfig['configurable_product_image']);
8086
}
8187
}

0 commit comments

Comments
 (0)