Skip to content

Commit b9bae61

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into AC-13818
2 parents fb8e83b + 2b17d9b commit b9bae61

File tree

40 files changed

+993
-770
lines changed

40 files changed

+993
-770
lines changed

app/code/Magento/CatalogInventory/Model/StockStateProvider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\CatalogInventory\Model;
@@ -159,7 +159,7 @@ public function checkQuoteItemQty(StockItemInterface $stockItem, $qty, $summaryQ
159159
if (!$stockItem->getIsInStock()) {
160160
$result->setHasError(true)
161161
->setErrorCode('out_stock')
162-
->setMessage(__('This product is out of stock.'))
162+
->setMessage(__('Product %name is out of stock.', ['name' => $stockItem->getProductName()]))
163163
->setQuoteMessage(__('Some of the products are out of stock.'))
164164
->setQuoteMessageIndex('stock');
165165
$result->setItemUseOldQty(true);

app/code/Magento/CatalogInventory/i18n/en_US.csv

+1
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ Stock,Stock
7777
"Only %s of %s available","Only %s of %s available"
7878
"Not enough items for sale","Not enough items for sale"
7979
"The requested qty. is not available","The requested qty. is not available"
80+
"Product %name is out of stock.","Product %name is out of stock."

app/code/Magento/Csp/Test/Unit/Plugin/StoreAssetIntegrityHashesTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -62,7 +62,6 @@ protected function setUp(): void
6262
* Test After Deploy method of plugin
6363
*
6464
* @return void
65-
* @doesNotPerformAssertions
6665
*/
6766
public function testAfterDeploy(): void
6867
{

app/code/Magento/Customer/Test/Unit/Model/AccountManagementApiTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -433,8 +433,6 @@ public function testBeforeCreateAccount(
433433
): void {
434434
if ($willThrowException) {
435435
$this->expectException(AuthorizationException::class);
436-
} else {
437-
$this->expectNotToPerformAssertions();
438436
}
439437
$this->authorizationMock
440438
->expects($this->once())

app/code/Magento/Customer/Test/Unit/Plugin/AsyncRequestCustomerGroupAuthorizationTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -86,7 +86,6 @@ public function testBeforePublishMass(
8686
[$customer, 'Password1', '']
8787
];
8888
$this->authorizationMock
89-
->expects($this->once())
9089
->method('isAllowed')
9190
->with('Magento_Customer::manage')
9291
->willReturn($isAllowed);

app/code/Magento/OrderCancellation/Model/Email/ConfirmationKeySender.php

+11-19
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,28 @@ public function __construct(
5151
* Send email to guest user with confirmation key.
5252
*
5353
* @param Order $order
54-
* @param string $confirmationKey
54+
* @param array $confirmationDetails
5555
* @return void
5656
* @throws LocalizedException
5757
*/
5858
public function execute(
5959
Order $order,
60-
string $confirmationKey,
60+
array $confirmationDetails
6161
):void {
6262
try {
6363
$storeId = (int)$order->getStoreId();
64-
$guestOrderUrl = $this->url->getUrl(
65-
self::ORDER_VIEW_PATH,
66-
[
67-
'_query' => [
68-
'confirmation_key' => $confirmationKey,
69-
'order_id' => $order->getIncrementId()
70-
]
71-
]
72-
);
73-
$templateParams = [
74-
'customer_name' => $order->getCustomerName(),
75-
'order_id' => $order->getIncrementId(),
76-
'guest_order_url' => $guestOrderUrl,
77-
'escaper' => $this->escaper,
78-
];
79-
8064
$this->transportBuilder
8165
->setTemplateIdentifier(self::TEMPLATE_ID)
8266
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
83-
->setTemplateVars($templateParams)
67+
->setTemplateVars([
68+
'customer_name' => $order->getCustomerName(),
69+
'order_id' => $order->getIncrementId(),
70+
'guest_order_url' => $this->url->getUrl(
71+
self::ORDER_VIEW_PATH,
72+
['_query' => $confirmationDetails]
73+
),
74+
'escaper' => $this->escaper,
75+
])
8476
->setFromByScope($this->orderIdentity->getEmailIdentity(), $storeId)
8577
->addTo($order->getCustomerEmail(), $order->getCustomerName())
8678
->getTransport()

app/code/Magento/OrderCancellation/Model/ResourceModel/SalesOrderConfirmCancel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function get(int $orderId): ?array
4040
$connection = $this->resourceConnection->getConnection();
4141
return $connection->fetchRow(
4242
$connection->select()->from(
43-
self::TABLE_NAME
43+
$this->resourceConnection->getTableName(self::TABLE_NAME)
4444
)->where(
4545
'order_id = ?',
4646
$orderId
@@ -60,7 +60,7 @@ public function insert(int $orderId, string $confirmationKey, string $reason): v
6060
{
6161
$connection = $this->resourceConnection->getConnection();
6262
$connection->insertOnDuplicate(
63-
self::TABLE_NAME,
63+
$this->resourceConnection->getTableName(self::TABLE_NAME),
6464
[
6565
'order_id' => $orderId,
6666
'confirmation_key' => $confirmationKey,

app/code/Magento/OrderCancellationGraphQl/Model/CancelOrderGuest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\OrderCancellationGraphQl\Model;
99

1010
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\GraphQl\Query\Uid;
1112
use Magento\OrderCancellation\Model\Email\ConfirmationKeySender;
1213
use Magento\OrderCancellation\Model\GetConfirmationKey;
1314
use Magento\Sales\Api\OrderRepositoryInterface;
@@ -23,12 +24,14 @@ class CancelOrderGuest
2324
* @param OrderRepositoryInterface $orderRepository
2425
* @param ConfirmationKeySender $confirmationKeySender
2526
* @param GetConfirmationKey $confirmationKey
27+
* @param Uid $idEncoder
2628
*/
2729
public function __construct(
2830
private readonly OrderFormatter $orderFormatter,
2931
private readonly OrderRepositoryInterface $orderRepository,
3032
private readonly ConfirmationKeySender $confirmationKeySender,
3133
private readonly GetConfirmationKey $confirmationKey,
34+
private readonly Uid $idEncoder
3235
) {
3336
}
3437

@@ -65,7 +68,13 @@ public function execute(Order $order, array $input): array
6568
*/
6669
private function sendConfirmationKeyEmail(Order $order, string $reason): void
6770
{
68-
$this->confirmationKeySender->execute($order, $this->confirmationKey->execute($order, $reason));
71+
$this->confirmationKeySender->execute(
72+
$order,
73+
[
74+
'order_id' => $this->idEncoder->encode((string)$order->getEntityId()),
75+
'confirmation_key' => $this->confirmationKey->execute($order, $reason)
76+
]
77+
);
6978

7079
// add comment in order about confirmation key send
7180
$order->addCommentToStatusHistory(

app/code/Magento/OrderCancellationGraphQl/Model/Resolver/CancelOrder.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1313
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Query\Uid;
1415
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1516
use Magento\OrderCancellation\Model\CancelOrder as CancelOrderAction;
1617
use Magento\OrderCancellationGraphQl\Model\Validator\ValidateOrder;
@@ -31,13 +32,15 @@ class CancelOrder implements ResolverInterface
3132
* @param OrderRepositoryInterface $orderRepository
3233
* @param CancelOrderAction $cancelOrderAction
3334
* @param ValidateOrder $validateOrder
35+
* @param Uid $idEncoder
3436
*/
3537
public function __construct(
3638
private readonly ValidateRequest $validateRequest,
3739
private readonly OrderFormatter $orderFormatter,
3840
private readonly OrderRepositoryInterface $orderRepository,
3941
private readonly CancelOrderAction $cancelOrderAction,
40-
private readonly ValidateOrder $validateOrder
42+
private readonly ValidateOrder $validateOrder,
43+
private readonly Uid $idEncoder
4144
) {
4245
}
4346

@@ -54,7 +57,7 @@ public function resolve(
5457
$this->validateRequest->execute($context, $args['input'] ?? []);
5558

5659
try {
57-
$order = $this->orderRepository->get($args['input']['order_id']);
60+
$order = $this->orderRepository->get($this->idEncoder->decode($args['input']['order_id']));
5861

5962
if ((int)$order->getCustomerId() !== $context->getUserId()) {
6063
throw new GraphQlAuthorizationException(__('Current user is not authorized to cancel this order'));

app/code/Magento/OrderCancellationGraphQl/Model/Resolver/ConfirmCancelOrder.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\GraphQl\Query\Uid;
1314
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1415
use Magento\OrderCancellationGraphQl\Model\ConfirmCancelOrder as ConfirmCancelOrderGuest;
1516
use Magento\OrderCancellationGraphQl\Model\Validator\ValidateOrder;
@@ -28,12 +29,14 @@ class ConfirmCancelOrder implements ResolverInterface
2829
* @param OrderRepositoryInterface $orderRepository
2930
* @param ConfirmCancelOrderGuest $confirmCancelOrder
3031
* @param ValidateOrder $validateOrder
32+
* @param Uid $idEncoder
3133
*/
3234
public function __construct(
3335
private readonly ValidateConfirmRequest $validateRequest,
3436
private readonly OrderRepositoryInterface $orderRepository,
3537
private readonly ConfirmCancelOrderGuest $confirmCancelOrder,
36-
private readonly ValidateOrder $validateOrder
38+
private readonly ValidateOrder $validateOrder,
39+
private readonly Uid $idEncoder
3740
) {
3841
}
3942

@@ -50,7 +53,7 @@ public function resolve(
5053
$this->validateRequest->execute($args['input'] ?? []);
5154

5255
try {
53-
$order = $this->orderRepository->get($args['input']['order_id']);
56+
$order = $this->orderRepository->get((int)$this->idEncoder->decode($args['input']['order_id']));
5457

5558
if (!$order->getCustomerIsGuest()) {
5659
return [

app/code/Magento/OrderCancellationGraphQl/Model/Validator/ValidateConfirmRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function execute(mixed $input): void
3030
);
3131
}
3232

33-
if (!$input['order_id'] || (int)$input['order_id'] === 0) {
33+
if (empty($input['order_id'])) {
3434
throw new GraphQlInputException(
3535
__(
3636
'Required parameter "%field" is missing or incorrect.',

app/code/Magento/OrderCancellationGraphQl/Model/Validator/ValidateRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function execute(
3838
);
3939
}
4040

41-
if (!$input['order_id'] || (int)$input['order_id'] === 0) {
41+
if (empty($input['order_id'])) {
4242
throw new GraphQlInputException(
4343
__(
4444
'Required parameter "%field" is missing or incorrect.',

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -14,8 +14,6 @@
1414
</argument>
1515
</arguments>
1616
</type>
17-
<preference for="Magento\SalesGraphQl\Api\OrderAvailableActionProviderInterface"
18-
type="Magento\OrderCancellationGraphQl\Model\GetOrderCancellationAvailableActions" />
1917
<type name="Magento\SalesGraphQl\Model\GetOrderAvailableActions">
2018
<arguments>
2119
<argument name="actions" xsi:type="array">

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ type Mutation {
1717
}
1818

1919
input CancelOrderInput @doc(description: "Defines the order to cancel.") {
20-
order_id: ID! @doc(description: "Order ID.")
20+
order_id: ID! @doc(description: "The unique ID of an `Order` type.")
2121
reason: String! @doc(description: "Cancellation reason.")
2222
}
2323

2424
input ConfirmCancelOrderInput {
25-
order_id: ID! @doc(description: "Order ID.")
25+
order_id: ID! @doc(description: "The unique ID of an `Order` type.")
2626
confirmation_key: String! @doc(description: "Confirmation Key to cancel the order.")
2727
}
2828

@@ -51,6 +51,6 @@ enum CancelOrderErrorCode {
5151
INVALID_ORDER_STATUS
5252
}
5353

54-
enum OrderActionType @doc(description: "The list of available order actions.") {
54+
enum OrderActionType {
5555
CANCEL
5656
}

app/code/Magento/OrderCancellationUi/view/frontend/web/js/cancel-order-modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ mutation cancelOrder($order_id: ID!, $reason: String!) {
4949
data: JSON.stringify({
5050
query: mutation,
5151
variables: {
52-
'order_id': config.order_id,
52+
'order_id': btoa(config.order_id),
5353
'reason': reason
5454
}
5555
}),

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -191,12 +191,13 @@ protected function _processActionData($action = null)
191191
*/
192192
$this->_getOrderCreateModel()->getBillingAddress();
193193

194+
$shippingMethod = $this->_getOrderCreateModel()->getShippingAddress()?->getShippingMethod();
195+
194196
/**
195197
* Flag for using billing address for shipping
196198
*/
197199
if (!$this->_getOrderCreateModel()->getQuote()->isVirtual()) {
198200
$syncFlag = $this->getRequest()->getPost('shipping_as_billing');
199-
$shippingMethod = $this->_getOrderCreateModel()->getShippingAddress()->getShippingMethod();
200201
if ($syncFlag === null
201202
&& $this->_getOrderCreateModel()->getShippingAddress()->getSameAsBilling() && empty($shippingMethod)
202203
) {
@@ -289,6 +290,7 @@ protected function _processActionData($action = null)
289290
$eventData = [
290291
'order_create_model' => $this->_getOrderCreateModel(),
291292
'request' => $this->getRequest()->getPostValue(),
293+
'shipping_method' => $shippingMethod
292294
];
293295

294296
$this->_eventManager->dispatch('adminhtml_sales_order_create_process_data', $eventData);

app/code/Magento/Sales/Model/AdminOrder/Create.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ protected function _initShippingAddressFromOrder(\Magento\Sales\Model\Order $ord
708708
* @param int $qty
709709
* @return \Magento\Quote\Model\Quote\Item|string|$this
710710
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
711+
* @throws LocalizedException
711712
*/
712713
public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $qty = null)
713714
{
@@ -733,9 +734,14 @@ public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $q
733734

734735
$this->formattedOptions($product, $buyRequest, $productOptions);
735736

736-
$item = $this->getQuote()->addProduct($product, $buyRequest);
737-
if (is_string($item)) {
738-
return $item;
737+
try {
738+
$item = $this->getQuote()->addProduct($product, $buyRequest);
739+
if (is_string($item)) {
740+
return $item;
741+
}
742+
} catch (LocalizedException $e) {
743+
$this->messageManager->addErrorMessage(__($e->getMessage()));
744+
return $this;
739745
}
740746

741747
if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {

0 commit comments

Comments
 (0)