Skip to content

Commit 821d884

Browse files
authored
LYNX-304: Added StoreConfig extra fields
1 parent 6b34507 commit 821d884

File tree

9 files changed

+193
-2
lines changed

9 files changed

+193
-2
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,12 @@
6060
</argument>
6161
</arguments>
6262
</type>
63+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
64+
<arguments>
65+
<argument name="extendedConfigData" xsi:type="array">
66+
<item name="is_guest_checkout_enabled" xsi:type="string">checkout/options/guest_checkout</item>
67+
<item name="is_one_page_checkout_enabled" xsi:type="string">checkout/options/onepage_checkout_enabled</item>
68+
</argument>
69+
</arguments>
70+
</type>
6371
</config>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,7 @@ enum CartUserInputErrorType {
442442
UNDEFINED
443443
}
444444

445+
type StoreConfig {
446+
is_guest_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/guest_checkout")
447+
is_one_page_checkout_enabled: Boolean @doc(description: "Extended Config Data - checkout/options/onepage_checkout_enabled")
448+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<arguments>
2828
<argument name="extendedConfigData" xsi:type="array">
2929
<item name="use_store_in_url" xsi:type="string">web/url/use_store</item>
30+
<item name="default_country" xsi:type="string">general/country/default</item>
31+
<item name="countries_with_required_region" xsi:type="string">general/region/state_required</item>
32+
<item name="display_state_if_optional" xsi:type="string">general/region/display_all</item>
33+
<item name="optional_zip_countries" xsi:type="string">general/country/optional_zip_countries</item>
3034
</argument>
3135
</arguments>
3236
</type>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ type StoreConfig @doc(description: "Contains information about a store's configu
4343
secure_base_static_url : String @doc(description: "The secure fully-qualified URL that specifies the location of static view files.")
4444
secure_base_media_url : String @doc(description: "The secure fully-qualified URL that specifies the location of media files.")
4545
use_store_in_url: Boolean @doc(description: "Indicates whether the store code should be used in the URL.")
46+
default_country: String @doc(description: "Extended Config Data - general/country/default")
47+
countries_with_required_region: String @doc(description: "Extended Config Data - general/region/state_required")
48+
optional_zip_countries: String @doc(description: "Extended Config Data - general/country/optional_zip_countries")
49+
display_state_if_optional: Boolean @doc(description: "Extended Config Data - general/region/display_all")
4650
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2023 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
20+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
21+
<arguments>
22+
<argument name="extendedConfigData" xsi:type="array">
23+
<item name="shopping_cart_display_price" xsi:type="string">tax/cart_display/price</item>
24+
<item name="shopping_cart_display_shipping" xsi:type="string">tax/cart_display/shipping</item>
25+
<item name="shopping_cart_display_subtotal" xsi:type="string">tax/cart_display/subtotal</item>
26+
<item name="shopping_cart_display_grand_total" xsi:type="string">tax/cart_display/grandtotal</item>
27+
<item name="shopping_cart_display_full_summary" xsi:type="string">tax/cart_display/full_summary</item>
28+
<item name="shopping_cart_display_zero_tax" xsi:type="string">tax/cart_display/zero_tax</item>
29+
</argument>
30+
</arguments>
31+
</type>
32+
</config>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@
44
enum PriceAdjustmentCodesEnum {
55
TAX @deprecated(reason: "`PriceAdjustmentCodesEnum` is deprecated. Tax is included or excluded in the price. Tax is not shown separately in Catalog.")
66
}
7+
8+
type StoreConfig {
9+
shopping_cart_display_price: Int @doc(description: "Extended Config Data - tax/cart_display/price")
10+
shopping_cart_display_shipping: Int @doc(description: "Extended Config Data - tax/cart_display/shipping")
11+
shopping_cart_display_subtotal: Int @doc(description: "Extended Config Data - tax/cart_display/subtotal")
12+
shopping_cart_display_grand_total: Boolean @doc(description: "Extended Config Data - tax/cart_display/grandtotal")
13+
shopping_cart_display_full_summary: Boolean @doc(description: "Extended Config Data - tax/cart_display/full_summary")
14+
shopping_cart_display_zero_tax: Boolean @doc(description: "Extended Config Data - tax/cart_display/zero_tax")
15+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\Quote;
9+
10+
use Magento\Checkout\Helper\Data;
11+
use Magento\Store\Model\ScopeInterface;
12+
use Magento\TestFramework\Fixture\Config as ConfigFixture;
13+
use Magento\TestFramework\TestCase\GraphQlAbstract;
14+
15+
/**
16+
* Test the GraphQL endpoint's StoreConfigs query
17+
*/
18+
class StoreConfigResolverTest extends GraphQlAbstract
19+
{
20+
#[
21+
ConfigFixture(Data::XML_PATH_GUEST_CHECKOUT, true, ScopeInterface::SCOPE_STORE, 'default'),
22+
ConfigFixture('checkout/options/onepage_checkout_enabled', true, ScopeInterface::SCOPE_STORE, 'default'),
23+
]
24+
public function testGetStoreConfig(): void
25+
{
26+
$query
27+
= <<<QUERY
28+
{
29+
storeConfig {
30+
is_guest_checkout_enabled,
31+
is_one_page_checkout_enabled,
32+
}
33+
}
34+
QUERY;
35+
$response = $this->graphQlQuery($query);
36+
$this->assertArrayHasKey('storeConfig', $response);
37+
$this->validateStoreConfig($response['storeConfig']);
38+
}
39+
40+
/**
41+
* Validate Store Config Data
42+
*
43+
* @param array $responseConfig
44+
*/
45+
private function validateStoreConfig(
46+
array $responseConfig,
47+
): void {
48+
$this->assertTrue($responseConfig['is_guest_checkout_enabled']);
49+
$this->assertTrue($responseConfig['is_one_page_checkout_enabled']);
50+
}
51+
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
namespace Magento\GraphQl\Store;
99

10+
use Magento\Directory\Helper\Data;
1011
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Store\Api\Data\StoreConfigInterface;
1213
use Magento\Store\Api\StoreConfigManagerInterface;
1314
use Magento\Store\Api\StoreRepositoryInterface;
1415
use Magento\Store\Api\StoreResolverInterface;
16+
use Magento\Store\Model\ScopeInterface;
1517
use Magento\Store\Model\Store;
18+
use Magento\TestFramework\Fixture\Config;
1619
use Magento\TestFramework\Helper\Bootstrap;
1720
use Magento\TestFramework\ObjectManager;
1821
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -39,6 +42,12 @@ protected function setUp(): void
3942
* @magentoApiDataFixture Magento/Store/_files/store.php
4043
* @throws NoSuchEntityException
4144
*/
45+
#[
46+
Config(Data::XML_PATH_DEFAULT_COUNTRY, 'es', ScopeInterface::SCOPE_STORE, 'default'),
47+
Config(Data::XML_PATH_STATES_REQUIRED, 'us', ScopeInterface::SCOPE_STORE, 'default'),
48+
Config(Data::OPTIONAL_ZIP_COUNTRIES_CONFIG_PATH, 'fr', ScopeInterface::SCOPE_STORE, 'default'),
49+
Config(Data::XML_PATH_DISPLAY_ALL_STATES, true, ScopeInterface::SCOPE_STORE, 'default'),
50+
]
4251
public function testGetStoreConfig(): void
4352
{
4453
/** @var StoreConfigManagerInterface $storeConfigManager */
@@ -80,7 +89,10 @@ public function testGetStoreConfig(): void
8089
secure_base_link_url,
8190
secure_base_static_url,
8291
secure_base_media_url,
83-
store_name
92+
default_country,
93+
countries_with_required_region,
94+
optional_zip_countries,
95+
display_state_if_optional
8496
}
8597
}
8698
QUERY;
@@ -136,6 +148,9 @@ private function validateStoreConfig(
136148
$this->assertEquals($storeConfig->getSecureBaseLinkUrl(), $responseConfig['secure_base_link_url']);
137149
$this->assertEquals($storeConfig->getSecureBaseStaticUrl(), $responseConfig['secure_base_static_url']);
138150
$this->assertEquals($storeConfig->getSecureBaseMediaUrl(), $responseConfig['secure_base_media_url']);
139-
$this->assertEquals($store->getName(), $responseConfig['store_name']);
151+
$this->assertEquals('es', $responseConfig['default_country']);
152+
$this->assertEquals('us', $responseConfig['countries_with_required_region']);
153+
$this->assertEquals('fr', $responseConfig['optional_zip_countries']);
154+
$this->assertEquals('true', $responseConfig['display_state_if_optional']);
140155
}
141156
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\Tax;
9+
10+
use Magento\Directory\Helper\Data;
11+
use Magento\Store\Model\ScopeInterface;
12+
use Magento\TestFramework\Fixture\Config as ConfigFixture;
13+
use Magento\TestFramework\TestCase\GraphQlAbstract;
14+
use Magento\Tax\Model\Config;
15+
16+
/**
17+
* Test the GraphQL endpoint's StoreConfigs query
18+
*/
19+
class StoreConfigResolverTest extends GraphQlAbstract
20+
{
21+
#[
22+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_PRICE, 1, ScopeInterface::SCOPE_STORE, 'default'),
23+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_SHIPPING, 1, ScopeInterface::SCOPE_STORE, 'default'),
24+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_SUBTOTAL, 1, ScopeInterface::SCOPE_STORE, 'default'),
25+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_GRANDTOTAL, 1, ScopeInterface::SCOPE_STORE, 'default'),
26+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_FULL_SUMMARY, 1, ScopeInterface::SCOPE_STORE, 'default'),
27+
ConfigFixture(Config::XML_PATH_DISPLAY_CART_ZERO_TAX, 1, ScopeInterface::SCOPE_STORE, 'default'),
28+
]
29+
public function testGetStoreConfig(): void
30+
{
31+
$query
32+
= <<<QUERY
33+
{
34+
storeConfig {
35+
shopping_cart_display_price,
36+
shopping_cart_display_shipping,
37+
shopping_cart_display_subtotal,
38+
shopping_cart_display_grand_total,
39+
shopping_cart_display_full_summary,
40+
shopping_cart_display_zero_tax,
41+
}
42+
}
43+
QUERY;
44+
$response = $this->graphQlQuery($query);
45+
$this->assertArrayHasKey('storeConfig', $response);
46+
$this->validateStoreConfig($response['storeConfig']);
47+
}
48+
49+
/**
50+
* Validate Store Config Data
51+
*
52+
* @param array $responseConfig
53+
*/
54+
private function validateStoreConfig(
55+
array $responseConfig,
56+
): void {
57+
$this->assertEquals(1, $responseConfig['shopping_cart_display_price']);
58+
$this->assertEquals(1, $responseConfig['shopping_cart_display_shipping']);
59+
$this->assertEquals(1, $responseConfig['shopping_cart_display_subtotal']);
60+
$this->assertEquals(1, $responseConfig['shopping_cart_display_grand_total']);
61+
$this->assertEquals(1, $responseConfig['shopping_cart_display_full_summary']);
62+
$this->assertEquals(1, $responseConfig['shopping_cart_display_zero_tax']);
63+
}
64+
}

0 commit comments

Comments
 (0)