Skip to content

Commit 83c7c32

Browse files
committed
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop-MFTF2.5.2
2 parents 02ce71f + 1de5f67 commit 83c7c32

File tree

36 files changed

+1331
-201
lines changed

36 files changed

+1331
-201
lines changed

app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function __construct(
6767
*/
6868
public function execute(int $customerId, array $data): AddressInterface
6969
{
70+
// It is needed because AddressInterface has country_id field.
71+
if (isset($data['country_code'])) {
72+
$data['country_id'] = $data['country_code'];
73+
}
7074
$this->validateData($data);
7175

7276
/** @var AddressInterface $address */

app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ public function execute(AddressInterface $address): array
127127

128128
$addressData['customer_id'] = null;
129129

130+
if (isset($addressData['country_id'])) {
131+
$addressData['country_code'] = $addressData['country_id'];
132+
}
133+
130134
return $addressData;
131135
}
132136
}

app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public function __construct(
6666
*/
6767
public function execute(AddressInterface $address, array $data): void
6868
{
69+
if (isset($data['country_code'])) {
70+
$data['country_id'] = $data['country_code'];
71+
}
6972
$this->validateData($data);
7073

7174
$filteredData = array_diff_key($data, array_flip($this->restrictedKeys));

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ input CustomerAddressInput {
2828
city: String @doc(description: "The city or town")
2929
region: CustomerAddressRegionInput @doc(description: "An object containing the region name, region code, and region ID")
3030
postcode: String @doc(description: "The customer's ZIP or postal code")
31-
country_id: CountryCodeEnum @doc(description: "The customer's country")
31+
country_id: CountryCodeEnum @doc(description: "Deprecated: use `country_code` instead.")
32+
country_code: CountryCodeEnum @doc(description: "The customer's country")
3233
default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address")
3334
default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address")
3435
fax: String @doc(description: "The fax number")
@@ -102,7 +103,8 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform
102103
customer_id: Int @doc(description: "The customer ID") @deprecated(reason: "customer_id is not needed as part of CustomerAddress, address ID (id) is unique identifier for the addresses.")
103104
region: CustomerAddressRegion @doc(description: "An object containing the region name, region code, and region ID")
104105
region_id: Int @deprecated(reason: "Region ID is excessive on storefront and region code should suffice for all scenarios")
105-
country_id: String @doc(description: "The customer's country")
106+
country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use `country_code` instead.")
107+
country_code: CountryCodeEnum @doc(description: "The customer's country")
106108
street: [String] @doc(description: "An array of strings that define the street number and name")
107109
company: String @doc(description: "The customer's company")
108110
telephone: String @doc(description: "The telephone number")

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

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

88
namespace Magento\QuoteGraphQl\Model\Cart;
99

10-
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Exception\InputException;
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -52,7 +52,7 @@ public function execute(
5252
$this->billingAddressManagement->assign($cart->getId(), $billingAddress, $useForShipping);
5353
} catch (NoSuchEntityException $e) {
5454
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
55-
} catch (LocalizedException $e) {
55+
} catch (InputException $e) {
5656
throw new GraphQlInputException(__($e->getMessage()), $e);
5757
}
5858
}

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

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

88
namespace Magento\QuoteGraphQl\Model\Cart;
99

10-
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Exception\InputException;
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -50,7 +50,7 @@ public function execute(
5050
$this->shippingAddressManagement->assign($cart->getId(), $shippingAddress);
5151
} catch (NoSuchEntityException $e) {
5252
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
53-
} catch (LocalizedException $e) {
53+
} catch (InputException $e) {
5454
throw new GraphQlInputException(__($e->getMessage()), $e);
5555
}
5656
}

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

Lines changed: 0 additions & 48 deletions
This file was deleted.

app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ private function getDiscountValues($cartItem, $currencyCode)
9393
foreach ($itemDiscounts as $value) {
9494
$discount = [];
9595
$amount = [];
96-
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
97-
$discountData = $value['discount'];
98-
/* @var \Magento\SalesRule\Model\Rule $rule */
99-
$rule = $value['rule'];
100-
$discount['label'] = $rule->getStoreLabel($cartItem->getQuote()->getStore()) ?: __('Discount');
101-
$amount['value'] = $discountData->getAmount();
96+
/* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
97+
$discountData = $value->getDiscountData();
98+
$discountAmount = $discountData->getAmount();
99+
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
100+
$amount['value'] = $discountAmount;
102101
$amount['currency'] = $currencyCode;
103102
$discount['amount'] = $amount;
104103
$discountValues[] = $discount;

app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,12 @@
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
1313
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1414
use Magento\Quote\Model\Quote;
15-
use Magento\QuoteGraphQl\Model\Cart\DiscountAggregator;
1615

1716
/**
1817
* @inheritdoc
1918
*/
2019
class Discounts implements ResolverInterface
2120
{
22-
/**
23-
* @var DiscountAggregator
24-
*/
25-
private $discountAggregator;
26-
27-
/**
28-
* @param DiscountAggregator|null $discountAggregator
29-
*/
30-
public function __construct(
31-
DiscountAggregator $discountAggregator
32-
) {
33-
$this->discountAggregator = $discountAggregator;
34-
}
35-
3621
/**
3722
* @inheritdoc
3823
*/
@@ -55,15 +40,16 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5540
private function getDiscountValues(Quote $quote)
5641
{
5742
$discountValues=[];
58-
$totalDiscounts = $this->discountAggregator->aggregateDiscountPerRule($quote);
59-
if ($totalDiscounts) {
43+
$address = $quote->getShippingAddress();
44+
$totalDiscounts = $address->getExtensionAttributes()->getDiscounts();
45+
if ($totalDiscounts && is_array($totalDiscounts)) {
6046
foreach ($totalDiscounts as $value) {
6147
$discount = [];
6248
$amount = [];
63-
/* @var \Magento\SalesRule\Model\Rule $rule*/
64-
$rule = $value['rule'];
65-
$discount['label'] = $rule->getStoreLabel($quote->getStore()) ?: __('Discount');
66-
$amount['value'] = $value['discount'];
49+
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
50+
/* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
51+
$discountData = $value->getDiscountData();
52+
$amount['value'] = $discountData->getAmount();
6753
$amount['currency'] = $quote->getQuoteCurrencyCode();
6854
$discount['amount'] = $amount;
6955
$discountValues[] = $discount;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Query {
77

88
type CustomerOrder @doc(description: "Order mapping fields") {
99
id: Int
10-
increment_id: String @deprecated(reason: "Use the order_number instaed.")
10+
increment_id: String @deprecated(reason: "Use the order_number instead.")
1111
order_number: String! @doc(description: "The order number")
1212
created_at: String
1313
grand_total: Float

0 commit comments

Comments
 (0)