Skip to content

Commit bb5267e

Browse files
Merge branch '2.4-develop' into AC-13229
2 parents 737f1a5 + df07984 commit bb5267e

File tree

26 files changed

+222
-253
lines changed

26 files changed

+222
-253
lines changed

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/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>

app/code/Magento/Sales/Model/Reorder/Reorder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class Reorder
6464
'The fewest you may purchase is' => self::ERROR_INSUFFICIENT_STOCK,
6565
'The most you may purchase is' => self::ERROR_INSUFFICIENT_STOCK,
6666
'The requested qty is not available' => self::ERROR_INSUFFICIENT_STOCK,
67+
'Not enough items for sale' => self::ERROR_INSUFFICIENT_STOCK,
68+
'Only %s of %s available' => self::ERROR_INSUFFICIENT_STOCK,
6769
];
6870

6971
/**
@@ -358,7 +360,7 @@ private function addError(string $message, string $code = null): void
358360
private function getErrorCode(string $message): string
359361
{
360362
$code = self::ERROR_UNDEFINED;
361-
363+
$message = preg_replace('/\d+/', '%s', $message);
362364
$matchedCodes = array_filter(
363365
self::MESSAGE_CODES,
364366
function ($key) use ($message) {

app/code/Magento/Sales/Test/Mftf/Test/AdminAddSelectedProductToOrderTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@
7171
<argument name="productQty" value="1"/>
7272
</actionGroup>
7373
<!-- Check that error remains -->
74-
<see userInput="The requested qty is not available" stepKey="assertProductErrorRemains"/>
74+
<see userInput="Not enough items for sale" stepKey="assertProductErrorRemains"/>
7575
</test>
7676
</tests>

0 commit comments

Comments
 (0)