Skip to content

Commit fee63b1

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MC-19746
2 parents 6fe5c10 + 32305e0 commit fee63b1

File tree

65 files changed

+1860
-221
lines changed

Some content is hidden

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

65 files changed

+1860
-221
lines changed

app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface;
1111
use Magento\Framework\Stdlib\ArrayManager;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1213

1314
/**
1415
* SetPaymentMethod additional data provider model for Authorizenet payment method
@@ -36,10 +37,32 @@ public function __construct(
3637
*
3738
* @param array $data
3839
* @return array
40+
* @throws GraphQlInputException
3941
*/
4042
public function getData(array $data): array
4143
{
42-
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data) ?? [];
44+
if (!isset($data[self::PATH_ADDITIONAL_DATA])) {
45+
throw new GraphQlInputException(
46+
__('Required parameter "authorizenet_acceptjs" for "payment_method" is missing.')
47+
);
48+
}
49+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_descriptor'])) {
50+
throw new GraphQlInputException(
51+
__('Required parameter "opaque_data_descriptor" for "authorizenet_acceptjs" is missing.')
52+
);
53+
}
54+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_value'])) {
55+
throw new GraphQlInputException(
56+
__('Required parameter "opaque_data_value" for "authorizenet_acceptjs" is missing.')
57+
);
58+
}
59+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['cc_last_4'])) {
60+
throw new GraphQlInputException(
61+
__('Required parameter "cc_last_4" for "authorizenet_acceptjs" is missing.')
62+
);
63+
}
64+
65+
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data);
4366
foreach ($additionalData as $key => $value) {
4467
$additionalData[$this->convertSnakeCaseToCamelCase($key)] = $value;
4568
unset($additionalData[$key]);

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function __construct(
3939
$this->locator = $locator;
4040
$this->arrayManager = $arrayManager;
4141
}
42-
42+
4343
/**
44-
* {@inheritdoc}
44+
* @inheritdoc
4545
*/
4646
public function modifyMeta(array $meta)
4747
{
@@ -64,7 +64,7 @@ public function modifyMeta(array $meta)
6464
$this->arrayManager->findPath(
6565
ProductAttributeInterface::CODE_PRICE,
6666
$meta,
67-
null,
67+
self::DEFAULT_GENERAL_PANEL . '/children',
6868
'children'
6969
) . static::META_CONFIG_PATH,
7070
$meta,
@@ -94,7 +94,7 @@ public function modifyMeta(array $meta)
9494
}
9595

9696
/**
97-
* {@inheritdoc}
97+
* @inheritdoc
9898
*/
9999
public function modifyData(array $data)
100100
{

app/code/Magento/Catalog/Block/Product/View/Details.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function getGroupSortedChildNames(string $groupName, string $callback): a
3737
$alias = $layout->getElementAlias($childName);
3838
$sortOrder = (int)$this->getChildData($alias, 'sort_order') ?? 0;
3939

40-
$childNamesSortOrder[$sortOrder] = $childName;
40+
$childNamesSortOrder[$childName] = $sortOrder;
4141
}
4242

43-
ksort($childNamesSortOrder, SORT_NUMERIC);
43+
asort($childNamesSortOrder, SORT_NUMERIC);
4444

45-
return $childNamesSortOrder;
45+
return array_keys($childNamesSortOrder);
4646
}
4747
}

app/code/Magento/Catalog/Model/Product/TierPriceManagement.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,19 @@ public function getList($sku, $customerGroupId)
182182
: $customerGroupId);
183183

184184
$prices = [];
185-
foreach ($product->getData('tier_price') as $price) {
186-
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
187-
|| ($customerGroupId === 'all' && $price['all_groups'])
188-
) {
189-
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
190-
$tierPrice = $this->priceFactory->create();
191-
$tierPrice->setValue($price[$priceKey])
192-
->setQty($price['price_qty'])
193-
->setCustomerGroupId($cgi);
194-
$prices[] = $tierPrice;
185+
$tierPrices = $product->getData('tier_price');
186+
if ($tierPrices !== null) {
187+
foreach ($tierPrices as $price) {
188+
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
189+
|| ($customerGroupId === 'all' && $price['all_groups'])
190+
) {
191+
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
192+
$tierPrice = $this->priceFactory->create();
193+
$tierPrice->setValue($price[$priceKey])
194+
->setQty($price['price_qty'])
195+
->setCustomerGroupId($cgi);
196+
$prices[] = $tierPrice;
197+
}
195198
}
196199
}
197200
return $prices;

app/code/Magento/CatalogGraphQl/Model/Resolver/CategoryTree.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
use Magento\Catalog\Model\Category;
1111
use Magento\CatalogGraphQl\Model\Resolver\Category\CheckCategoryIsActive;
1212
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ExtractDataFromCategoryTree;
13-
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1413
use Magento\Framework\GraphQl\Config\Element\Field;
15-
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1614
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1715
use Magento\Framework\GraphQl\Query\ResolverInterface;
16+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree as CategoryTreeDataProvider;
1818

1919
/**
2020
* Category tree field resolver, used for GraphQL request processing.
@@ -27,7 +27,7 @@ class CategoryTree implements ResolverInterface
2727
const CATEGORY_INTERFACE = 'CategoryInterface';
2828

2929
/**
30-
* @var \Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree
30+
* @var CategoryTreeDataProvider
3131
*/
3232
private $categoryTree;
3333

@@ -42,12 +42,12 @@ class CategoryTree implements ResolverInterface
4242
private $checkCategoryIsActive;
4343

4444
/**
45-
* @param \Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree $categoryTree
45+
* @param CategoryTreeDataProvider $categoryTree
4646
* @param ExtractDataFromCategoryTree $extractDataFromCategoryTree
4747
* @param CheckCategoryIsActive $checkCategoryIsActive
4848
*/
4949
public function __construct(
50-
\Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree $categoryTree,
50+
CategoryTreeDataProvider $categoryTree,
5151
ExtractDataFromCategoryTree $extractDataFromCategoryTree,
5252
CheckCategoryIsActive $checkCategoryIsActive
5353
) {
@@ -56,22 +56,6 @@ public function __construct(
5656
$this->checkCategoryIsActive = $checkCategoryIsActive;
5757
}
5858

59-
/**
60-
* Get category id
61-
*
62-
* @param array $args
63-
* @return int
64-
* @throws GraphQlInputException
65-
*/
66-
private function getCategoryId(array $args) : int
67-
{
68-
if (!isset($args['id'])) {
69-
throw new GraphQlInputException(__('"id for category should be specified'));
70-
}
71-
72-
return (int)$args['id'];
73-
}
74-
7559
/**
7660
* @inheritdoc
7761
*/
@@ -81,7 +65,9 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8165
return $value[$field->getName()];
8266
}
8367

84-
$rootCategoryId = $this->getCategoryId($args);
68+
$rootCategoryId = isset($args['id']) ? (int)$args['id'] :
69+
(int)$context->getExtensionAttributes()->getStore()->getRootCategoryId();
70+
8571
if ($rootCategoryId !== Category::TREE_ROOT_ID) {
8672
$this->checkCategoryIsActive->execute($rootCategoryId);
8773
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\CatalogGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Query\ResolverInterface;
12+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13+
14+
/**
15+
* Root category tree field resolver, used for GraphQL request processing.
16+
*/
17+
class RootCategoryId implements ResolverInterface
18+
{
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
23+
{
24+
return (int)$context->getExtensionAttributes()->getStore()->getRootCategoryId();
25+
}
26+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ type StoreConfig @doc(description: "The type contains information about a store
416416
grid_per_page : Int @doc(description: "Products per Page on Grid Default Value.")
417417
list_per_page : Int @doc(description: "Products per Page on List Default Value.")
418418
catalog_default_sort_by : String @doc(description: "Default Sort By.")
419+
root_category_id: Int @doc(description: "The ID of the root category") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\RootCategoryId")
419420
}
420421

421422
type ProductVideo @doc(description: "Contains information about a product video.") implements MediaGalleryInterface {

app/code/Magento/Checkout/Controller/Cart/UpdateItemQty.php

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@
88
namespace Magento\Checkout\Controller\Cart;
99

1010
use Magento\Checkout\Model\Cart\RequestQuantityProcessor;
11+
use Magento\Checkout\Model\Session as CheckoutSession;
12+
use Magento\Framework\App\Action\Action;
1113
use Magento\Framework\App\Action\Context;
14+
use Magento\Framework\App\Action\HttpPostActionInterface;
15+
use Magento\Framework\Data\Form\FormKey\Validator as FormKeyValidator;
1216
use Magento\Framework\Exception\LocalizedException;
13-
use Magento\Checkout\Model\Session as CheckoutSession;
17+
use Magento\Framework\Exception\NotFoundException;
1418
use Magento\Framework\Serialize\Serializer\Json;
15-
use Magento\Framework\Data\Form\FormKey\Validator as FormKeyValidator;
1619
use Magento\Quote\Model\Quote\Item;
1720
use Psr\Log\LoggerInterface;
1821

19-
class UpdateItemQty extends \Magento\Framework\App\Action\Action
22+
/**
23+
* UpdateItemQty ajax request
24+
*
25+
* @package Magento\Checkout\Controller\Cart
26+
*/
27+
class UpdateItemQty extends Action implements HttpPostActionInterface
2028
{
29+
2130
/**
2231
* @var RequestQuantityProcessor
2332
*/
@@ -44,13 +53,16 @@ class UpdateItemQty extends \Magento\Framework\App\Action\Action
4453
private $logger;
4554

4655
/**
47-
* @param Context $context,
56+
* UpdateItemQty constructor
57+
*
58+
* @param Context $context
4859
* @param RequestQuantityProcessor $quantityProcessor
4960
* @param FormKeyValidator $formKeyValidator
5061
* @param CheckoutSession $checkoutSession
5162
* @param Json $json
5263
* @param LoggerInterface $logger
5364
*/
65+
5466
public function __construct(
5567
Context $context,
5668
RequestQuantityProcessor $quantityProcessor,
@@ -68,30 +80,26 @@ public function __construct(
6880
}
6981

7082
/**
83+
* Controller execute method
84+
*
7185
* @return void
7286
*/
7387
public function execute()
7488
{
7589
try {
76-
if (!$this->formKeyValidator->validate($this->getRequest())) {
77-
throw new LocalizedException(
78-
__('Something went wrong while saving the page. Please refresh the page and try again.')
79-
);
80-
}
90+
$this->validateRequest();
91+
$this->validateFormKey();
8192

8293
$cartData = $this->getRequest()->getParam('cart');
83-
if (!is_array($cartData)) {
84-
throw new LocalizedException(
85-
__('Something went wrong while saving the page. Please refresh the page and try again.')
86-
);
87-
}
94+
95+
$this->validateCartData($cartData);
8896

8997
$cartData = $this->quantityProcessor->process($cartData);
9098
$quote = $this->checkoutSession->getQuote();
9199

92100
foreach ($cartData as $itemId => $itemInfo) {
93101
$item = $quote->getItemById($itemId);
94-
$qty = isset($itemInfo['qty']) ? (double)$itemInfo['qty'] : 0;
102+
$qty = isset($itemInfo['qty']) ? (double) $itemInfo['qty'] : 0;
95103
if ($item) {
96104
$this->updateItemQuantity($item, $qty);
97105
}
@@ -111,11 +119,13 @@ public function execute()
111119
*
112120
* @param Item $item
113121
* @param float $qty
122+
* @return void
114123
* @throws LocalizedException
115124
*/
116125
private function updateItemQuantity(Item $item, float $qty)
117126
{
118127
if ($qty > 0) {
128+
$item->clearMessage();
119129
$item->setQty($qty);
120130

121131
if ($item->getHasError()) {
@@ -145,9 +155,7 @@ private function jsonResponse(string $error = '')
145155
*/
146156
private function getResponseData(string $error = ''): array
147157
{
148-
$response = [
149-
'success' => true,
150-
];
158+
$response = ['success' => true];
151159

152160
if (!empty($error)) {
153161
$response = [
@@ -158,4 +166,48 @@ private function getResponseData(string $error = ''): array
158166

159167
return $response;
160168
}
169+
170+
/**
171+
* Validates the Request HTTP method
172+
*
173+
* @return void
174+
* @throws NotFoundException
175+
*/
176+
private function validateRequest()
177+
{
178+
if ($this->getRequest()->isPost() === false) {
179+
throw new NotFoundException(__('Page Not Found'));
180+
}
181+
}
182+
183+
/**
184+
* Validates form key
185+
*
186+
* @return void
187+
* @throws LocalizedException
188+
*/
189+
private function validateFormKey()
190+
{
191+
if (!$this->formKeyValidator->validate($this->getRequest())) {
192+
throw new LocalizedException(
193+
__('Something went wrong while saving the page. Please refresh the page and try again.')
194+
);
195+
}
196+
}
197+
198+
/**
199+
* Validates cart data
200+
*
201+
* @param array|null $cartData
202+
* @return void
203+
* @throws LocalizedException
204+
*/
205+
private function validateCartData($cartData = null)
206+
{
207+
if (!is_array($cartData)) {
208+
throw new LocalizedException(
209+
__('Something went wrong while saving the page. Please refresh the page and try again.')
210+
);
211+
}
212+
}
161213
}

0 commit comments

Comments
 (0)