Skip to content

Commit 79c7f5d

Browse files
committed
Merge branch 'MC-20636' of github.com:magento-honey-badgers/magento2ce into MC-20636
2 parents be24253 + 9658785 commit 79c7f5d

File tree

8 files changed

+62
-53
lines changed

8 files changed

+62
-53
lines changed

app/code/Magento/SalesGraphQl/Model/InvoiceItemInterfaceTypeResolverComposite.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public function __construct(array $productTypeNameResolvers = [])
2929
}
3030

3131
/**
32-
* @inheritdoc
32+
* Resolve item type of an invoice through composite resolvers
33+
*
34+
* @param array $data
35+
* @return string
3336
* @throws GraphQlInputException
3437
*/
3538
public function resolveType(array $data): string

app/code/Magento/SalesGraphQl/Model/OrderItemInterfaceTypeResolverComposite.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public function __construct(array $productTypeNameResolvers = [])
2929
}
3030

3131
/**
32-
* {@inheritdoc}
32+
* Resolve item type of an order through composite resolvers
33+
*
34+
* @param array $data
35+
* @return string
3336
* @throws GraphQlInputException
3437
*/
3538
public function resolveType(array $data) : string

app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ private function getBundleOptions(
9595
$bundleOptions[$bundleOptionId]['label'] = $bundleOption['label'] ?? '';
9696
$bundleOptions[$bundleOptionId]['id'] = isset($bundleOption['option_id']) ?
9797
base64_encode($bundleOption['option_id']) : null;
98-
$optionItems = $this->formatBundleOptionItems(
99-
$item,
100-
$bundleOption
101-
);
102-
$bundleOptions[$bundleOptionId]['values'] = $optionItems['items'] ?? [];
98+
if (isset($bundleOption['option_id'])) {
99+
$bundleOptions[$bundleOptionId]['values'] = $this->formatBundleOptionItems(
100+
$item,
101+
$bundleOption['option_id']
102+
);
103+
} else {
104+
$bundleOptions[$bundleOptionId]['values'] = [];
105+
}
103106
}
104107
}
105108
return $bundleOptions;
@@ -109,37 +112,35 @@ private function getBundleOptions(
109112
* Format Bundle items
110113
*
111114
* @param OrderItemInterface $item
112-
* @param array $bundleOption
115+
* @param string $bundleOptionId
113116
* @return array
114117
*/
115118
private function formatBundleOptionItems(
116119
OrderItemInterface $item,
117-
array $bundleOption
120+
string $bundleOptionId
118121
) {
119122
$optionItems = [];
120-
$optionItems['items'] = [];
121-
foreach ($bundleOption['value'] ?? [] as $bundleOptionValueKey => $bundleOptionValue) {
122-
// Find the item assign to the option
123-
/** @var OrderItemInterface $childrenOrderItem */
124-
foreach ($item->getChildrenItems() ?? [] as $childrenOrderItem) {
125-
$childOrderItemOptions = $childrenOrderItem->getProductOptions();
126-
$bundleChildAttributes = $this->serializer
127-
->unserialize($childOrderItemOptions['bundle_selection_attributes']);
128-
// Value Id is missing from parent, so we have to match the child to parent option
129-
if (isset($bundleChildAttributes['option_id'])
130-
&& $bundleChildAttributes['option_id'] == $bundleOption['option_id']) {
131-
$optionItems['items'][$childrenOrderItem->getItemId()] = [
132-
'id' => base64_encode($childrenOrderItem->getItemId()),
133-
'product_name' => $childrenOrderItem->getName(),
134-
'product_sku' => $childrenOrderItem->getSku(),
135-
'quantity' => $bundleChildAttributes['qty'],
136-
'price' => [
137-
'value' => $bundleChildAttributes['price']
138-
]
139-
];
140-
}
123+
// Find the item assign to the option
124+
/** @var OrderItemInterface $childrenOrderItem */
125+
foreach ($item->getChildrenItems() ?? [] as $childrenOrderItem) {
126+
$childOrderItemOptions = $childrenOrderItem->getProductOptions();
127+
$bundleChildAttributes = $this->serializer
128+
->unserialize($childOrderItemOptions['bundle_selection_attributes'] ?? '');
129+
// Value Id is missing from parent, so we have to match the child to parent option
130+
if (isset($bundleChildAttributes['option_id'])
131+
&& $bundleChildAttributes['option_id'] == $bundleOptionId) {
132+
$optionItems[$childrenOrderItem->getItemId()] = [
133+
'id' => base64_encode($childrenOrderItem->getItemId()),
134+
'product_name' => $childrenOrderItem->getName(),
135+
'product_sku' => $childrenOrderItem->getSku(),
136+
'quantity' => $bundleChildAttributes['qty'],
137+
'price' => [
138+
'value' => $bundleChildAttributes['price']
139+
]
140+
];
141141
}
142142
}
143+
143144
return $optionItems;
144145
}
145146
}

app/code/Magento/SalesGraphQl/Model/Resolver/CustomerOrders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function resolve(
7777
$orders[] = [
7878
'created_at' => $order['created_at'],
7979
'grand_total' => $order['grand_total'],
80-
'id' => $order['entity_id'],
80+
'id' => base64_encode($order['entity_id']),
8181
'increment_id' => $order['increment_id'],
8282
'number' => $order['increment_id'],
8383
'order_date' => $order['created_at'],

app/code/Magento/SalesGraphQl/Model/Resolver/OrderTotal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function resolve(
4141
$index = $key;
4242
$appliedTaxType = $appliedTaxForItem->getType();
4343
$taxLineItems = $appliedTaxForItem->getAppliedTaxes();
44-
foreach ($taxLineItems as $new => $taxLineItem) {
44+
foreach ($taxLineItems as $taxLineItem) {
4545
$allAppliedTaxesForItemsData[$key][$index]['title'] = $taxLineItem->getDataByKey('title');
4646
$allAppliedTaxesForItemsData[$key][$index]['percent'] = $taxLineItem->getDataByKey('percent');
4747
$allAppliedTaxesForItemsData[$key][$index]['amount'] = $taxLineItem->getDataByKey('amount');
@@ -136,7 +136,7 @@ private function getAppliedTaxesDetails(Order $order, array $appliedTaxesArray):
136136
if (empty($appliedTaxesArray)) {
137137
$taxes [] = [];
138138
} else {
139-
foreach ($appliedTaxesArray as $key => $appliedTaxes) {
139+
foreach ($appliedTaxesArray as $key => $appliedTaxes) {
140140
if (empty($appliedTaxes[$key])) {
141141
$taxes [] = [
142142
'title' => $appliedTaxes[$key]['title'] ?? " ",

app/code/Magento/SalesGraphQl/Model/Resolver/Orders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function resolve(
5555
/** @var Order $order */
5656
foreach ($orders as $order) {
5757
$items[] = [
58-
'id' => base64_encode($order->getId()),
58+
'id' => $order->getId(),
5959
'increment_id' => $order->getIncrementId(),
6060
'order_number' => $order->getIncrementId(),
6161
'created_at' => $order->getCreatedAt(),

app/code/Magento/SalesGraphQl/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"magento/module-sales": "*",
99
"magento/module-store": "*",
1010
"magento/module-catalog": "*",
11-
"magento/module-shipping": "*",
1211
"magento/module-graph-ql": "*"
1312
},
1413
"suggest": {

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/RetrieveOrdersByOrderNumberTest.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ public function testGetMatchingOrdersForLowerQueryLength()
462462
/**
463463
* @magentoApiDataFixture Magento/Customer/_files/customer.php
464464
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
465+
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
466+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
465467
*/
466468
public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
467469
{
@@ -816,7 +818,8 @@ public function testGetCustomerOrdersTwoStoreViewQuery(string $orderNumber, stri
816818
$query,
817819
[],
818820
'',
819-
array_merge($this->customerAuthenticationHeader->execute(
821+
array_merge(
822+
$this->customerAuthenticationHeader->execute(
820823
$currentEmail, $currentPassword),
821824
['Store' => $store]
822825
)
@@ -924,24 +927,23 @@ private function assertTotalsWithTaxesAndDiscountsOnShippingAndTotal(array $cust
924927
$this->assertCount(2, $customerOrderItem['total']['taxes']);
925928
$expectedProductAndShippingTaxes =
926929
[
927-
[
930+
[
928931
'amount' => [
929-
'value' => 2.7,
930-
'currency' => 'USD'
931-
],
932-
'title' => 'US-TEST-*-Rate-1',
933-
'rate' => 7.5
934-
],
935-
[
936-
'amount' => [
937-
'value' => 1.35,
938-
'currency' => 'USD'
932+
'value' => 2.7,
933+
'currency' => 'USD',
934+
],
935+
'title' => 'US-TEST-*-Rate-1',
936+
'rate' => 7.5,
939937
],
940-
941-
'title' => 'US-TEST-*-Rate-1',
942-
'rate' => 7.5
943-
]
944-
];
938+
[
939+
'amount' => [
940+
'value' => 1.35,
941+
'currency' => 'USD'
942+
],
943+
'title' => 'US-TEST-*-Rate-1',
944+
'rate' => 7.5,
945+
]
946+
];
945947
$this->assertEquals($expectedProductAndShippingTaxes, $customerOrderItem['total']['taxes']);
946948
$this->assertEquals(
947949
21.5,
@@ -1377,7 +1379,8 @@ private function setPaymentMethod(string $cartId, array $method): void
13771379
$currentEmail = '[email protected]';
13781380
$currentPassword = 'password';
13791381
$this->graphQlMutation(
1380-
$query, [],
1382+
$query,
1383+
[],
13811384
'',
13821385
$this->customerAuthenticationHeader->execute($currentEmail, $currentPassword)
13831386
);

0 commit comments

Comments
 (0)