Skip to content

Commit 6122144

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MC-20075
2 parents 669fd01 + 502abab commit 6122144

File tree

92 files changed

+4679
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4679
-414
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a
1111

1212
* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html).
1313

14+
## Learn More About GraphQL in Magento 2
15+
16+
* [GraphQL Developer Guide](https://devdocs.magento.com/guides/v2.3/graphql/index.html)
17+
1418
<h2>Contributing to the Magento 2 Code Base</h2>
1519
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
1620

app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<section name="LocaleOptionsSection">
1212
<element name="sectionHeader" type="text" selector="#general_locale-head"/>
1313
<element name="timezone" type="select" selector="#general_locale_timezone"/>
14+
<element name="locale" type="select" selector="#general_locale_code"/>
15+
<element name="localeEnabled" type="select" selector="#general_locale_code:enabled"/>
16+
<element name="localeDisabled" type="select" selector="#general_locale_code[disabled=disabled]"/>
1417
<element name="useDefault" type="checkbox" selector="#general_locale_timezone_inherit"/>
1518
</section>
1619
</sections>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<title value="Check locale dropdown and developer configuration page are available in developer mode"/>
15+
<description value="Check locale dropdown and developer configuration page are available in developer mode"/>
16+
<group value="backend"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-20374"/>
19+
<group value="developer_mode_only"/>
20+
<group value="mtf_migrated"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
</before>
25+
26+
<!-- Go to the general configuration and make sure the locale dropdown is available and enabled -->
27+
<actionGroup ref="AdminOpenStoreConfigPageActionGroup" stepKey="openStoreConfigPage" />
28+
<scrollTo selector="{{LocaleOptionsSection.sectionHeader}}" stepKey="scrollToLocaleSection" x="0" y="-80" />
29+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSection"/>
30+
<seeElement selector="{{LocaleOptionsSection.localeEnabled}}" stepKey="seeEnabledLocaleDropdown"/>
31+
32+
<!-- Go to the developer configuration and make sure the page is available -->
33+
<actionGroup ref="AdminOpenStoreConfigDeveloperPageActionGroup" stepKey="goToDeveloperConfigPage"/>
34+
<seeInCurrentUrl url="{{AdminConfigDeveloperPage.url}}" stepKey="seeDeveloperConfigUrl"/>
35+
<seeElement selector="{{AdminConfigSection.navItemByTitle('Developer')}}" stepKey="assertDeveloperNavItemPresent" />
36+
</test>
37+
</tests>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCheckLocaleAndDeveloperConfigInProductionModeTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<title value="Check locale dropdown and developer configuration page are not available in production mode"/>
15+
<description value="Check locale dropdown and developer configuration page are not available in production mode"/>
16+
<testCaseId value="MC-14106" />
17+
<severity value="MAJOR"/>
18+
<group value="backend"/>
19+
<group value="production_mode_only"/>
20+
<group value="mtf_migrated"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
</before>
25+
26+
<!-- Go to the general configuration and make sure the locale dropdown is disabled -->
27+
<actionGroup ref="AdminOpenStoreConfigPageActionGroup" stepKey="openStoreConfigPage" />
28+
<scrollTo selector="{{LocaleOptionsSection.sectionHeader}}" stepKey="scrollToLocaleSection" x="0" y="-80" />
29+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}" dependentSelector="{{LocaleOptionsSection.timezone}}" visible="false" stepKey="openLocaleSection"/>
30+
<assertElementContainsAttribute selector="{{LocaleOptionsSection.locale}}" attribute="disabled" stepKey="seeDisabledLocaleDropdown" />
31+
32+
<!-- Go to the developer configuration and make sure the redirect to the configuration page takes place -->
33+
<actionGroup ref="AdminOpenStoreConfigDeveloperPageActionGroup" stepKey="goToDeveloperConfigPage"/>
34+
<seeInCurrentUrl url="{{AdminConfigPage.url}}index/" stepKey="seeConfigurationIndexUrl"/>
35+
36+
<actionGroup ref="AdminExpandConfigTabActionGroup" stepKey="expandAdvancedTab">
37+
<argument name="tabName" value="Advanced" />
38+
</actionGroup>
39+
<dontSeeElement selector="{{AdminConfigSection.navItemByTitle('Developer')}}" stepKey="assertDeveloperNavItemAbsent" />
40+
</test>
41+
</tests>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ input PaymentMethodInput {
1111
}
1212

1313
input BraintreeInput {
14-
payment_method_nonce: String!
15-
is_active_payment_token_enabler: Boolean!
16-
device_data: String
14+
payment_method_nonce: String! @doc(description:"The one-time payment token generated by Braintree payment gateway based on card details. Required field to make sale transaction.")
15+
is_active_payment_token_enabler: Boolean! @doc(description:"States whether an entered by a customer credit/debit card should be tokenized for later usage. Required only if Vault is enabled for Braintree payment integration.")
16+
device_data: String @doc(description:"Contains a fingerprint provided by Braintree JS SDK and should be sent with sale transaction details to the Braintree payment gateway. Should be specified only in a case if Kount (advanced fraud protection) is enabled for Braintree payment integration.")
1717
}
1818

1919
input BraintreeCcVaultInput {
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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\CatalogCustomerGraphQl\Model\Resolver;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
12+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
13+
use Magento\Customer\Api\CustomerRepositoryInterface;
14+
use Magento\Customer\Model\GroupManagement;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17+
use Magento\Framework\GraphQl\Config\Element\Field;
18+
use Magento\Framework\GraphQl\Query\ResolverInterface;
19+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
20+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
21+
use Magento\Framework\Exception\NoSuchEntityException;
22+
23+
/**
24+
* @inheritdoc
25+
*/
26+
class TierPrices implements ResolverInterface
27+
{
28+
/**
29+
* @var Collection
30+
*/
31+
private $collection;
32+
33+
/**
34+
* @var CustomerRepositoryInterface
35+
*/
36+
private $customerRepository;
37+
38+
/**
39+
* @var ValueFactory
40+
*/
41+
private $valueFactory;
42+
43+
/**
44+
* @var int
45+
*/
46+
private $customerGroupId = null;
47+
48+
/**
49+
* @var array
50+
*/
51+
private $productIds = [];
52+
53+
/**
54+
* @param CollectionFactory $collectionFactory
55+
* @param ValueFactory $valueFactory
56+
* @param CustomerRepositoryInterface $customerRepository
57+
*/
58+
public function __construct(
59+
CollectionFactory $collectionFactory,
60+
ValueFactory $valueFactory,
61+
CustomerRepositoryInterface $customerRepository
62+
) {
63+
$this->collection = $collectionFactory->create();
64+
$this->valueFactory = $valueFactory;
65+
$this->customerRepository = $customerRepository;
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public function resolve(
72+
Field $field,
73+
$context,
74+
ResolveInfo $info,
75+
array $value = null,
76+
array $args = null
77+
) {
78+
if (!isset($value['model'])) {
79+
throw new LocalizedException(__('"model" value should be specified'));
80+
}
81+
82+
if (null === $this->customerGroupId) {
83+
$this->customerGroupId = $this->getCustomerGroupId($context);
84+
}
85+
86+
/** @var Product $product */
87+
$product = $value['model'];
88+
$productId = $product->getId();
89+
$this->productIds[] = $productId;
90+
$that = $this;
91+
92+
return $this->valueFactory->create(
93+
function () use ($that, $productId, $context) {
94+
$tierPrices = [];
95+
if (empty($that->productIds)) {
96+
return [];
97+
}
98+
if (!$that->collection->isLoaded()) {
99+
$that->collection->addIdFilter($that->productIds);
100+
$that->collection->addTierPriceDataByGroupId($that->customerGroupId);
101+
}
102+
/** @var \Magento\Catalog\Model\Product $item */
103+
foreach ($that->collection as $item) {
104+
if ($item->getId() === $productId) {
105+
// Try to extract all requested fields from the loaded collection data
106+
foreach ($item->getTierPrices() as $tierPrice) {
107+
$tierPrices[] = $tierPrice->getData();
108+
}
109+
}
110+
}
111+
return $tierPrices;
112+
}
113+
);
114+
}
115+
116+
/**
117+
* Get the customer group Id.
118+
*
119+
* @param \Magento\GraphQl\Model\Query\ContextInterface $context
120+
*
121+
* @return int
122+
*/
123+
private function getCustomerGroupId(\Magento\GraphQl\Model\Query\ContextInterface $context)
124+
{
125+
$currentUserId = $context->getUserId();
126+
if (!$currentUserId) {
127+
$customerGroupId = GroupManagement::NOT_LOGGED_IN_ID;
128+
} else {
129+
try {
130+
$customer = $this->customerRepository->getById($currentUserId);
131+
} catch (NoSuchEntityException $e) {
132+
throw new GraphQlNoSuchEntityException(
133+
__('Customer with id "%customer_id" does not exist.', ['customer_id' => $currentUserId]),
134+
$e
135+
);
136+
}
137+
$customerGroupId = $customer->getGroupId();
138+
}
139+
return $customerGroupId;
140+
}
141+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CatalogCustomerGraphQl
2+
3+
**CatalogCustomerGraphQl** provides type and resolver information for GraphQL attributes that have dependences on the Catalog and Customer modules.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "magento/module-catalog-customer-graph-ql",
3+
"description": "N/A",
4+
"type": "magento2-module",
5+
"require": {
6+
"php": "~7.1.3||~7.2.0||~7.3.0",
7+
"magento/module-catalog": "*",
8+
"magento/module-customer": "*",
9+
"magento/framework": "*",
10+
"magento/module-graph-ql": "*"
11+
},
12+
"license": [
13+
"OSL-3.0",
14+
"AFL-3.0"
15+
],
16+
"autoload": {
17+
"files": [
18+
"registration.php"
19+
],
20+
"psr-4": {
21+
"Magento\\CatalogCustomerGraphQl\\": ""
22+
}
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_CatalogCustomerGraphQl" >
10+
<sequence>
11+
<module name="Magento_Catalog"/>
12+
<module name="Magento_Customer"/>
13+
<module name="Magento_GraphQl"/>
14+
</sequence>
15+
</module>
16+
</config>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright © Magento, Inc. All rights reserved.
2+
# See COPYING.txt for license details.
3+
4+
interface ProductInterface {
5+
tier_prices: [ProductTierPrices] @doc(description: "An array of ProductTierPrices objects.") @resolver(class: "Magento\\CatalogCustomerGraphQl\\Model\\Resolver\\TierPrices")
6+
}
7+
8+
type ProductTierPrices @doc(description: "The ProductTierPrices object defines a tier price, which is a quantity discount offered to a specific customer group.") {
9+
customer_group_id: String @doc(description: "The ID of the customer group.")
10+
qty: Float @doc(description: "The number of items that must be purchased to qualify for tier pricing.")
11+
value: Float @doc(description: "The price of the fixed price item.")
12+
percentage_value: Float @doc(description: "The percentage discount of the item.")
13+
website_id: Float @doc(description: "The ID assigned to the website.")
14+
}

0 commit comments

Comments
 (0)