Skip to content

Commit 6ffd164

Browse files
committed
Merge branch '2.4-develop' into ACP2E-3350
2 parents 41cf801 + bafba2a commit 6ffd164

File tree

38 files changed

+543
-332
lines changed

38 files changed

+543
-332
lines changed

app/code/Magento/Backend/view/adminhtml/templates/dashboard/totalbar/refreshstatistics.phtml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
/** @var \Magento\Backend\Block\Template $block */
8+
/** @var \Magento\Framework\Escaper $escaper */
69
?>
710
<div class="page-actions">
811
<div class="page-actions-inner">
912
<div class="page-actions-buttons">
1013
<?= $block->getChildHtml() ?>
1114

15+
<?php if ($block->getAuthorization()->isAllowed('Magento_Reports::statistics')): ?>
1216
<form class="action-element"
13-
action="<?= $block->escapeUrl($block->getUrl('*/*/refreshStatistics')) ?>"
17+
action="<?= $escaper->escapeUrl($block->getUrl('*/*/refreshStatistics')) ?>"
1418
method="post">
1519
<input
1620
name="form_key"
1721
type="hidden"
18-
value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/>
22+
value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
1923
<button
2024
class="action-primary"
2125
type="submit"
22-
title="<?= $block->escapeHtmlAttr(__('Reload Data')) ?>">
23-
<?= $block->escapeHtml(__('Reload Data')) ?>
26+
title="<?= $escaper->escapeHtmlAttr(__('Reload Data')) ?>">
27+
<?= $escaper->escapeHtml(__('Reload Data')) ?>
2428
</button>
2529
</form>
30+
<?php endif; ?>
2631
</div>
2732
</div>
2833
</div>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityAcceptLowerThanStockQuantityAfterChangingStockInBackendTest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<description value="Verify if lower than stock product quantity is accepted after changing stock qty in backend"/>
1515
<severity value="CRITICAL"/>
1616
<testCaseId value="AC-5987"/>
17-
<group value="mtf_migrated"/>
17+
<group value="mtf_migrated"/>
1818
</annotations>
1919

2020
<before>
@@ -61,14 +61,14 @@
6161
<waitForAjaxLoad stepKey="waitForAjaxLoad1"/>
6262

6363
<!--Assert "The requested qty is not available"-->
64-
<see selector="{{CheckoutCartMessageSection.errorMessage}}" userInput="The requested qty is not available" stepKey="seeTheErrorMessageDisplayed"/>
64+
<see selector="{{CheckoutCartMessageSection.errorMessage}}" userInput="Not enough items for sale" stepKey="seeTheErrorMessageDisplayed"/>
6565

6666
<fillField selector="{{CheckoutCartProductSection.qty($$simpleProduct.sku$$)}}" userInput="8" stepKey="updateProductQty"/>
6767
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="clickUpdateShoppingCart"/>
6868
<waitForAjaxLoad stepKey="waitForAjaxLoad2"/>
6969
<waitForAjaxLoad stepKey="waitForPageLoad2"/>
7070

71-
<dontSee userInput="The requested qty is not available" stepKey="dontSeeTheErrorMessageDisplayed"/>
71+
<dontSee userInput="Not enough items for sale" stepKey="dontSeeTheErrorMessageDisplayed"/>
7272

7373
</test>
7474
</tests>

app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddProductToCartVerifyThatErrorMessageShouldNotDisappearTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<actionGroup ref="StorefrontProductPageAddSimpleProductToCartActionGroup" stepKey="addProductToCart"/>
5151
<!-- Check that error remains -->
5252
<actionGroup ref="StorefrontAssertProductAddToCartErrorMessageActionGroup" stepKey="assertFailure">
53-
<argument name="message" value="The requested qty is not available"/>
53+
<argument name="message" value="Not enough items for sale"/>
5454
</actionGroup>
5555
</test>
5656
</tests>

app/code/Magento/Developer/Console/Command/DiInfoCommand.php

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,26 @@
77
namespace Magento\Developer\Console\Command;
88

99
use Magento\Developer\Model\Di\Information;
10+
use Magento\Framework\ObjectManagerInterface;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Exception\InvalidArgumentException;
1213
use Symfony\Component\Console\Helper\Table;
1314
use Symfony\Component\Console\Input\InputArgument;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Output\OutputInterface;
17+
use Magento\Framework\App\AreaList;
18+
use Magento\Framework\App\Area;
1619

20+
/**
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
1723
class DiInfoCommand extends Command
1824
{
25+
/**
26+
* @var ObjectManagerInterface
27+
*/
28+
private ObjectManagerInterface $objectManager;
29+
1930
/**
2031
* Command name
2132
*/
@@ -26,18 +37,34 @@ class DiInfoCommand extends Command
2637
*/
2738
public const CLASS_NAME = 'class';
2839

40+
/**
41+
* Area name
42+
*/
43+
public const AREA_CODE = 'area';
44+
2945
/**
3046
* @var Information
3147
*/
32-
private $diInformation;
48+
private Information $diInformation;
49+
50+
/**
51+
* @var AreaList
52+
*/
53+
private AreaList $areaList;
3354

3455
/**
3556
* @param Information $diInformation
57+
* @param ObjectManagerInterface $objectManager
58+
* @param AreaList|null $areaList
3659
*/
3760
public function __construct(
38-
Information $diInformation
61+
Information $diInformation,
62+
ObjectManagerInterface $objectManager,
63+
?AreaList $areaList = null
3964
) {
4065
$this->diInformation = $diInformation;
66+
$this->objectManager = $objectManager;
67+
$this->areaList = $areaList ?? \Magento\Framework\App\ObjectManager::getInstance()->get(AreaList::class);
4168
parent::__construct();
4269
}
4370

@@ -49,10 +76,11 @@ public function __construct(
4976
protected function configure()
5077
{
5178
$this->setName(self::COMMAND_NAME)
52-
->setDescription('Provides information on Dependency Injection configuration for the Command.')
53-
->setDefinition([
54-
new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name')
55-
]);
79+
->setDescription('Provides information on Dependency Injection configuration for the Command.')
80+
->setDefinition([
81+
new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name'),
82+
new InputArgument(self::AREA_CODE, InputArgument::OPTIONAL, 'Area Code')
83+
]);
5684

5785
parent::configure();
5886
}
@@ -154,10 +182,14 @@ private function printPlugins($className, $output, $label)
154182
*/
155183
protected function execute(InputInterface $input, OutputInterface $output)
156184
{
185+
$area = $input->getArgument(self::AREA_CODE) ?? Area::AREA_GLOBAL;
186+
if ($area !== Area::AREA_GLOBAL) {
187+
$this->setDiArea($area);
188+
}
157189
$className = $input->getArgument(self::CLASS_NAME);
158190
$output->setDecorated(true);
159191
$output->writeln('');
160-
$output->writeln(sprintf('DI configuration for the class %s in the GLOBAL area', $className));
192+
$output->writeln(sprintf('DI configuration for the class %s in the %s area', $className, strtoupper($area)));
161193

162194
if ($this->diInformation->isVirtualType($className)) {
163195
$output->writeln(
@@ -173,4 +205,39 @@ protected function execute(InputInterface $input, OutputInterface $output)
173205

174206
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
175207
}
208+
209+
/**
210+
* Set Area for DI Configuration
211+
*
212+
* @param string $area
213+
* @return void
214+
* @throws \InvalidArgumentException
215+
*/
216+
private function setDiArea(string $area): void
217+
{
218+
if ($this->validateAreaCodeFromInput($area)) {
219+
$areaOmConfiguration = $this->objectManager
220+
->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)
221+
->load($area);
222+
223+
$this->objectManager->configure($areaOmConfiguration);
224+
225+
$this->objectManager->get(\Magento\Framework\Config\ScopeInterface::class)
226+
->setCurrentScope($area);
227+
} else {
228+
throw new InvalidArgumentException(sprintf('The "%s" area code does not exist', $area));
229+
}
230+
}
231+
232+
/**
233+
* Validate Input
234+
*
235+
* @param string $area
236+
* @return bool
237+
*/
238+
private function validateAreaCodeFromInput($area): bool
239+
{
240+
$availableAreaCodes = $this->areaList->getCodes();
241+
return in_array($area, $availableAreaCodes, true);
242+
}
176243
}

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

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@
1919
use Magento\Framework\GraphQl\Config\Element\Field;
2020
use Magento\Framework\GraphQl\Query\ResolverInterface;
2121
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
22-
use Magento\OrderCancellationGraphQl\Model\CancelOrderErrorCodes;
2322

2423
/**
2524
* Resolver to return the description of a CancellationReason with error code
2625
*/
2726
class CancelOrderError implements ResolverInterface
2827
{
2928
/**
30-
* @param CancelOrderErrorCodes $cancelOrderErrorCodes
29+
* @param array $errorMessageCodesMapper
3130
*/
3231
public function __construct(
33-
private readonly CancelOrderErrorCodes $cancelOrderErrorCodes
32+
private readonly array $errorMessageCodesMapper
3433
) {
3534
}
3635

@@ -50,7 +49,7 @@ public function resolve(
5049

5150
return [
5251
'message' => $value['error'],
53-
'code' => $this->cancelOrderErrorCodes->getErrorCodeFromMapper((string) $value['error']),
52+
'code' => $this->errorMessageCodesMapper[strtolower((string) $value['error'])] ?? 'UNDEFINED',
5453
];
5554
}
5655
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@
2323
</argument>
2424
</arguments>
2525
</type>
26+
<type name="Magento\OrderCancellationGraphQl\Model\Resolver\CancelOrderError">
27+
<arguments>
28+
<argument name="errorMessageCodesMapper" xsi:type="array">
29+
<item name="order cancellation is not enabled for requested store." xsi:type="string">ORDER_CANCELLATION_DISABLED</item>
30+
<item name="current user is not authorized to cancel this order" xsi:type="string">UNAUTHORISED</item>
31+
<item name="the entity that was requested doesn't exist. verify the entity and try again." xsi:type="string">ORDER_NOT_FOUND</item>
32+
<item name="order with one or more items shipped cannot be cancelled" xsi:type="string">PARTIAL_ORDER_ITEM_SHIPPED</item>
33+
<item name="order already closed, complete, cancelled or on hold" xsi:type="string">INVALID_ORDER_STATUS</item>
34+
</argument>
35+
</arguments>
36+
</type>
2637
</config>

app/code/Magento/Quote/Model/Cart/AddProductsToCartError.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class AddProductsToCartError
3333
'The fewest you may purchase is' => self::ERROR_INSUFFICIENT_STOCK,
3434
'The most you may purchase is' => self::ERROR_INSUFFICIENT_STOCK,
3535
'The requested qty is not available' => self::ERROR_INSUFFICIENT_STOCK,
36+
'Not enough items for sale' => self::ERROR_INSUFFICIENT_STOCK,
37+
'Only %s of %s available' => self::ERROR_INSUFFICIENT_STOCK,
3638
];
3739

3840
/**
@@ -59,6 +61,7 @@ public function create(string $message, int $cartItemPosition = 0): Data\Error
5961
*/
6062
private function getErrorCode(string $message): string
6163
{
64+
$message = preg_replace('/\d+/', '%s', $message);
6265
foreach (self::MESSAGE_CODES as $codeMessage => $code) {
6366
if (false !== stripos($message, $codeMessage)) {
6467
return $code;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
104104
*/
105105
private function getErrorCode(string $message): string
106106
{
107+
$message = preg_replace('/\d+/', '%s', $message);
107108
foreach ($this->messageCodesMapper as $key => $code) {
108109
if (str_contains($message, $key)) {
109110
return $code;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
<item name="Could not find cart item" xsi:type="string">COULD_NOT_FIND_CART_ITEM</item>
8787
<item name="Required parameter" xsi:type="string">REQUIRED_PARAMETER_MISSING</item>
8888
<item name="The fewest you may purchase" xsi:type="string">INVALID_PARAMETER_VALUE</item>
89+
<item name="Not enough items for sale" xsi:type="string">INSUFFICIENT_STOCK</item>
90+
<item name="Only %s of %s available" xsi:type="string">INSUFFICIENT_STOCK</item>
8991
</argument>
9092
</arguments>
9193
</type>

0 commit comments

Comments
 (0)