Skip to content

Commit a0bcc52

Browse files
committed
Merge remote-tracking branch 'origin/MC-6459' into 2.3-develop-mftf-pr20
# Conflicts: # dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php
2 parents c558921 + b0a8925 commit a0bcc52

File tree

84 files changed

+1554
-467
lines changed

Some content is hidden

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

84 files changed

+1554
-467
lines changed

app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private function fetch() : array
117117
'price' => $link->getSelectionPriceValue(),
118118
'position' => $link->getPosition(),
119119
'id' => $link->getSelectionId(),
120-
'qty' => (int)$link->getSelectionQty(),
120+
'qty' => (float)$link->getSelectionQty(),
121+
'quantity' => (float)$link->getSelectionQty(),
121122
'is_default' => (bool)$link->getIsDefault(),
122123
'price_type' => $this->enumLookup->getEnumValueFromField(
123124
'PriceTypeEnum',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ type BundleItem @doc(description: "BundleItem defines an individual item in a bu
1414
type BundleItemOption @doc(description: "BundleItemOption defines characteristics and options for a specific bundle item.") {
1515
id: Int @doc(description: "The ID assigned to the bundled item option.")
1616
label: String @doc(description: "The text that identifies the bundled item option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Label")
17-
qty: Float @doc(description: "Indicates the quantity of this specific bundle item.")
17+
qty: Float @deprecated(reason: "The `qty` is deprecated. Use `quantity` instead.") @doc(description: "Indicates the quantity of this specific bundle item.")
18+
quantity: Float @doc(description: "Indicates the quantity of this specific bundle item.")
1819
position: Int @doc(description: "When a bundle item contains multiple options, the relative position of this option compared to the other options.")
1920
is_default: Boolean @doc(description: "Indicates whether this option is the default option.")
2021
price: Float @doc(description: "The price of the selected option.")

app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,7 @@ define([
8787
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
8888
}
8989

90-
if (!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
91-
!cartCache.isChanged('shippingMethodCode', data.shippingMethodCode) &&
92-
!cartCache.isChanged('shippingCarrierCode', data.shippingCarrierCode) &&
93-
!cartCache.isChanged('address', address) &&
94-
cartCache.get('totals') &&
95-
!cartCache.isChanged('subtotal', parseFloat(quote.totals().subtotal))
96-
) {
97-
quote.setTotals(cartCache.get('totals'));
98-
} else {
99-
return loadFromServer(address);
100-
}
90+
return loadFromServer(address);
10191
}
10292
};
10393
});

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ define([
102102
self.isLoading(true);
103103
});
104104

105-
if (cartData().website_id !== window.checkout.websiteId ||
106-
cartData().store_id !== window.checkout.storeId
105+
if (
106+
cartData().website_id !== window.checkout.websiteId &&
107+
cartData().website_id !== undefined
107108
) {
108109
customerData.reload(['cart'], false);
109110
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\ConfigurableProductGraphQl\Model\Cart\BuyRequest;
9+
10+
use Magento\Framework\Stdlib\ArrayManager;
11+
use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface;
12+
13+
/**
14+
* DataProvider for building super attribute options in buy requests
15+
*/
16+
class SuperAttributeDataProvider implements BuyRequestDataProviderInterface
17+
{
18+
/**
19+
* @var ArrayManager
20+
*/
21+
private $arrayManager;
22+
23+
/**
24+
* @param ArrayManager $arrayManager
25+
*/
26+
public function __construct(
27+
ArrayManager $arrayManager
28+
) {
29+
$this->arrayManager = $arrayManager;
30+
}
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
public function execute(array $cartItemData): array
36+
{
37+
$superAttributes = $this->arrayManager->get('configurable_attributes', $cartItemData, []);
38+
39+
$superAttributesData = [];
40+
foreach ($superAttributes as $superAttribute) {
41+
$superAttributesData[$superAttribute['id']] = $superAttribute['value'];
42+
}
43+
44+
return ['super_attribute' => $superAttributesData];
45+
}
46+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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\ConfigurableProductGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14+
use Magento\QuoteGraphQl\Model\Cart\AddProductsToCart;
15+
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser;
16+
17+
/**
18+
* Add configurable products to cart GraphQl resolver
19+
* {@inheritdoc}
20+
*/
21+
class AddConfigurableProductsToCart implements ResolverInterface
22+
{
23+
/**
24+
* @var GetCartForUser
25+
*/
26+
private $getCartForUser;
27+
28+
/**
29+
* @var AddProductsToCart
30+
*/
31+
private $addProductsToCart;
32+
33+
/**
34+
* @param GetCartForUser $getCartForUser
35+
* @param AddProductsToCart $addProductsToCart
36+
*/
37+
public function __construct(
38+
GetCartForUser $getCartForUser,
39+
AddProductsToCart $addProductsToCart
40+
) {
41+
$this->getCartForUser = $getCartForUser;
42+
$this->addProductsToCart = $addProductsToCart;
43+
}
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
49+
{
50+
if (!isset($args['input']['cart_id']) || empty($args['input']['cart_id'])) {
51+
throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
52+
}
53+
$maskedCartId = $args['input']['cart_id'];
54+
55+
if (!isset($args['input']['cart_items']) || empty($args['input']['cart_items'])
56+
|| !is_array($args['input']['cart_items'])
57+
) {
58+
throw new GraphQlInputException(__('Required parameter "cart_items" is missing'));
59+
}
60+
$cartItems = $args['input']['cart_items'];
61+
62+
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
63+
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
64+
$this->addProductsToCart->execute($cart, $cartItems);
65+
66+
return [
67+
'cart' => [
68+
'model' => $cart,
69+
],
70+
];
71+
}
72+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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\ConfigurableProductGraphQl\Model\Resolver;
9+
10+
use Magento\Catalog\Helper\Product\Configuration;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14+
use Magento\Framework\GraphQl\Query\ResolverInterface;
15+
use Magento\Quote\Model\Quote\Item;
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
class ConfigurableCartItemOptions implements ResolverInterface
21+
{
22+
/**
23+
* @var Configuration
24+
*/
25+
private $configurationHelper;
26+
27+
/**
28+
* @param Configuration $configurationHelper
29+
*/
30+
public function __construct(
31+
Configuration $configurationHelper
32+
) {
33+
$this->configurationHelper = $configurationHelper;
34+
}
35+
36+
/**
37+
* Fetch and format configurable variants.
38+
*
39+
* @param Field $field
40+
* @param \Magento\Framework\GraphQl\Query\Resolver\ContextInterface $context
41+
* @param ResolveInfo $info
42+
* @param array|null $value
43+
* @param array|null $args
44+
* @return array|\Magento\Framework\GraphQl\Query\Resolver\Value|mixed
45+
* @throws LocalizedException
46+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
47+
*/
48+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
49+
{
50+
if (!isset($value['model'])) {
51+
throw new LocalizedException(__('"model" value should be specified'));
52+
}
53+
/** @var Item $cartItem */
54+
$cartItem = $value['model'];
55+
56+
$result = [];
57+
foreach ($this->configurationHelper->getOptions($cartItem) as $option) {
58+
$result[] = [
59+
'id' => $option['option_id'],
60+
'option_label' => $option['label'],
61+
'value_id' => $option['option_value'],
62+
'value_label' => $option['value'],
63+
];
64+
}
65+
66+
return $result;
67+
}
68+
}

app/code/Magento/ConfigurableProductGraphQl/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"magento/module-catalog": "*",
88
"magento/module-configurable-product": "*",
99
"magento/module-catalog-graph-ql": "*",
10+
"magento/module-quote": "*",
11+
"magento/module-quote-graph-ql": "*",
1012
"magento/framework": "*"
1113
},
1214
"license": [

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@
2222
</argument>
2323
</arguments>
2424
</type>
25+
<type name="Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestBuilder">
26+
<arguments>
27+
<argument name="providers" xsi:type="array">
28+
<item name="super_attribute" xsi:type="object">Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider</item>
29+
</argument>
30+
</arguments>
31+
</type>
2532
</config>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33
type Mutation {
4-
addConfigurableProductsToCart(input: AddConfigurableProductsToCartInput): AddConfigurableProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
4+
addConfigurableProductsToCart(input: AddConfigurableProductsToCartInput): AddConfigurableProductsToCartOutput @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\AddConfigurableProductsToCart")
55
}
66

77
type ConfigurableProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "ConfigurableProduct defines basic features of a configurable product and its simple product variants") {
@@ -50,13 +50,19 @@ type AddConfigurableProductsToCartOutput {
5050

5151
input ConfigurableProductCartItemInput {
5252
data: CartItemInput!
53-
variant_sku: String!
53+
variant_sku: String @deprecated(reason: "Use CartItemInput.sku instead")
54+
configurable_attributes: [ConfigurableCartItemAttributesInput]!
5455
customizable_options:[CustomizableOptionInput!]
5556
}
5657

58+
input ConfigurableCartItemAttributesInput {
59+
id: Int!
60+
value: Int!
61+
}
62+
5763
type ConfigurableCartItem implements CartItemInterface {
5864
customizable_options: [SelectedCustomizableOption]!
59-
configurable_options: [SelectedConfigurableOption!]!
65+
configurable_options: [SelectedConfigurableOption!]! @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\ConfigurableCartItemOptions")
6066
}
6167

6268
type SelectedConfigurableOption {

0 commit comments

Comments
 (0)