Skip to content

Commit b4afab3

Browse files
Merge pull request #8161 from magento-cia/cia-2.4.7-beta1-develop-bugfixes-02162023
cia-2.4.7-beta1-develop-bugfixes-02162023
2 parents 36968e0 + 91067a0 commit b4afab3

File tree

12 files changed

+206
-28
lines changed

12 files changed

+206
-28
lines changed

Diff for: app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
define([
77
'jquery',
8-
'mageUtils',
98
'jquery/ui',
109
'jquery/jstree/jquery.jstree'
11-
], function ($, utils) {
10+
], function ($) {
1211
'use strict';
1312

1413
$.widget('mage.categoryTree', {
@@ -87,7 +86,7 @@ define([
8786
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
8887
result = {
8988
id: node.id,
90-
text: utils.unescape(node.name) + ' (' + node.product_count + ')',
89+
text: node.name + ' (' + node.product_count + ')',
9190
li_attr: {
9291
class: node.cls + (!!node.disabled ? ' disabled' : '') //eslint-disable-line no-extra-boolean-cast
9392
},

Diff for: app/code/Magento/Checkout/etc/adminhtml/system.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<resource>Magento_Checkout::checkout</resource>
1414
<group id="options" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
1515
<label>Checkout Options</label>
16+
<field id="enable_guest_checkout_login" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
17+
<label>Enable Guest Checkout Login</label>
18+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
19+
<comment>Enabling this setting will allow unauthenticated users to query if an e-mail address is already associated with a customer account. This can be used to enhance the checkout workflow for guests that do not realize they already have an account but comes at the cost of exposing information to unauthenticated users.</comment>
20+
</field>
1621
<field id="onepage_checkout_enabled" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
1722
<label>Enable Onepage Checkout</label>
1823
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
@@ -23,7 +28,7 @@
2328
</field>
2429
<field id="display_billing_address_on" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
2530
<label>Display Billing Address On</label>
26-
<source_model>\Magento\Checkout\Model\Adminhtml\BillingAddressDisplayOptions</source_model>
31+
<source_model>Magento\Checkout\Model\Adminhtml\BillingAddressDisplayOptions</source_model>
2732
</field>
2833
<field id="max_items_display_count" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
2934
<label>Maximum Number of Items to Display in Order Summary</label>

Diff for: app/code/Magento/Checkout/etc/config.xml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<default>
1010
<checkout>
1111
<options>
12+
<enable_guest_checkout_login>0</enable_guest_checkout_login>
1213
<onepage_checkout_enabled>1</onepage_checkout_enabled>
1314
<guest_checkout>1</guest_checkout>
1415
<display_billing_address_on>0</display_billing_address_on>

Diff for: app/code/Magento/Customer/Api/AccountManagementInterface.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Customer\Api;
99

1010
use Magento\Framework\Exception\InputException;
11+
use Magento\Framework\Exception\LocalizedException;
1112

1213
/**
1314
* Interface for managing customers accounts.
@@ -194,7 +195,7 @@ public function resendConfirmation($email, $websiteId, $redirectUrl = '');
194195
* Check if given email is associated with a customer account in given website.
195196
*
196197
* @param string $customerEmail
197-
* @param int $websiteId If not set, will use the current websiteId
198+
* @param int|null $websiteId If not set, will use the current websiteId
198199
* @return bool
199200
* @throws \Magento\Framework\Exception\LocalizedException
200201
*/

Diff for: app/code/Magento/Customer/Model/AccountManagement.php

+23-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Customer\Model\Customer as CustomerModel;
2121
use Magento\Customer\Model\Customer\CredentialsValidator;
2222
use Magento\Customer\Model\ForgotPasswordToken\GetCustomerByToken;
23+
use Magento\Customer\Model\Logger as CustomerLogger;
2324
use Magento\Customer\Model\Metadata\Validator;
2425
use Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory;
2526
use Magento\Directory\Model\AllowedCountries;
@@ -57,7 +58,6 @@
5758
use Magento\Store\Model\ScopeInterface;
5859
use Magento\Store\Model\StoreManagerInterface;
5960
use Psr\Log\LoggerInterface as PsrLogger;
60-
use Magento\Customer\Model\Logger as CustomerLogger;
6161

6262
/**
6363
* Handle various customer account actions
@@ -69,6 +69,11 @@
6969
*/
7070
class AccountManagement implements AccountManagementInterface
7171
{
72+
/**
73+
* System Configuration Path for Enable/Disable Login at Guest Checkout
74+
*/
75+
public const GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG = 'checkout/options/enable_guest_checkout_login';
76+
7277
/**
7378
* Configuration paths for create account email template
7479
*
@@ -719,7 +724,7 @@ private function handleUnknownTemplate($template)
719724
throw new InputException(
720725
__(
721726
'Invalid value of "%value" provided for the %fieldName field. '
722-
. 'Possible values: %template1 or %template2.',
727+
. 'Possible values: %template1 or %template2.',
723728
[
724729
'value' => $template,
725730
'fieldName' => 'template',
@@ -1125,7 +1130,7 @@ public function validate(CustomerInterface $customer)
11251130
$result = $this->eavValidator->isValid($customerModel);
11261131
if ($result === false && is_array($this->eavValidator->getMessages())) {
11271132
return $validationResults->setIsValid(false)->setMessages(
1128-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1133+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
11291134
call_user_func_array(
11301135
'array_merge',
11311136
array_values($this->eavValidator->getMessages())
@@ -1137,9 +1142,24 @@ public function validate(CustomerInterface $customer)
11371142

11381143
/**
11391144
* @inheritdoc
1145+
*
1146+
* @param string $customerEmail
1147+
* @param int|null $websiteId
1148+
* @return bool
1149+
* @throws LocalizedException
11401150
*/
11411151
public function isEmailAvailable($customerEmail, $websiteId = null)
11421152
{
1153+
$guestLoginConfig = $this->scopeConfig->getValue(
1154+
self::GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG,
1155+
ScopeInterface::SCOPE_WEBSITE,
1156+
$websiteId
1157+
);
1158+
1159+
if (!$guestLoginConfig) {
1160+
return true;
1161+
}
1162+
11431163
try {
11441164
if ($websiteId === null) {
11451165
$websiteId = $this->storeManager->getStore()->getWebsiteId();

Diff for: app/code/Magento/QuoteGraphQl/Model/Resolver/RemoveItemFromCart.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8686
$itemId = $processedArgs['input']['cart_item_id'];
8787

8888
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
89+
/** Check if the current user is allowed to perform actions with the cart */
90+
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
8991

9092
try {
9193
$this->cartItemRepository->deleteById($cartId, $itemId);
@@ -95,7 +97,6 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
9597
throw new GraphQlInputException(__($e->getMessage()), $e);
9698
}
9799

98-
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
99100
return [
100101
'cart' => [
101102
'model' => $cart,

Diff for: dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

+28-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
use Magento\Customer\Api\Data\CustomerInterface as Customer;
1010
use Magento\Customer\Model\AccountManagement;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\App\ObjectManager;
1113
use Magento\Framework\Exception\InputException;
1214
use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
1315
use Magento\Newsletter\Model\Subscriber;
1416
use Magento\Security\Model\Config;
17+
use Magento\Store\Model\ScopeInterface;
1518
use Magento\TestFramework\Helper\Bootstrap;
1619
use Magento\TestFramework\Helper\Customer as CustomerHelper;
1720
use Magento\TestFramework\TestCase\WebapiAbstract;
@@ -23,15 +26,20 @@
2326
*/
2427
class AccountManagementTest extends WebapiAbstract
2528
{
26-
const SERVICE_VERSION = 'V1';
27-
const SERVICE_NAME = 'customerAccountManagementV1';
28-
const RESOURCE_PATH = '/V1/customers';
29+
public const SERVICE_VERSION = 'V1';
30+
public const SERVICE_NAME = 'customerAccountManagementV1';
31+
public const RESOURCE_PATH = '/V1/customers';
2932

3033
/**
3134
* Sample values for testing
3235
*/
33-
const ATTRIBUTE_CODE = 'attribute_code';
34-
const ATTRIBUTE_VALUE = 'attribute_value';
36+
public const ATTRIBUTE_CODE = 'attribute_code';
37+
public const ATTRIBUTE_VALUE = 'attribute_value';
38+
39+
/**
40+
* @var ObjectManager
41+
*/
42+
private $objectManager;
3543

3644
/**
3745
* @var AccountManagementInterface
@@ -86,6 +94,8 @@ class AccountManagementTest extends WebapiAbstract
8694
*/
8795
protected function setUp(): void
8896
{
97+
$this->objectManager = Bootstrap::getObjectManager();
98+
8999
$this->accountManagement = Bootstrap::getObjectManager()->get(
90100
\Magento\Customer\Api\AccountManagementInterface::class
91101
);
@@ -645,6 +655,7 @@ public function testIsReadonly()
645655

646656
public function testEmailAvailable()
647657
{
658+
$config = $this->objectManager->get(ScopeConfigInterface::class);
648659
$customerData = $this->_createCustomer();
649660

650661
$serviceInfo = [
@@ -662,7 +673,18 @@ public function testEmailAvailable()
662673
'customerEmail' => $customerData[Customer::EMAIL],
663674
'websiteId' => $customerData[Customer::WEBSITE_ID],
664675
];
665-
$this->assertFalse($this->_webApiCall($serviceInfo, $requestData));
676+
677+
$emailSetting = $config->getValue(
678+
AccountManagement::GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG,
679+
ScopeInterface::SCOPE_WEBSITE,
680+
$customerData[Customer::WEBSITE_ID]
681+
);
682+
683+
if (!$emailSetting) {
684+
$this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
685+
} else {
686+
$this->assertFalse($this->_webApiCall($serviceInfo, $requestData));
687+
}
666688
}
667689

668690
public function testEmailAvailableInvalidEmail()

Diff for: dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/IsEmailAvailableTest.php

+34-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,37 @@
77

88
namespace Magento\GraphQl\Customer;
99

10+
use Magento\Customer\Model\AccountManagement;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Store\Api\StoreResolverInterface;
13+
use Magento\Store\Model\ScopeInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
1015
use Magento\TestFramework\TestCase\GraphQlAbstract;
1116

1217
/**
1318
* Test email availability functionality
1419
*/
1520
class IsEmailAvailableTest extends GraphQlAbstract
1621
{
22+
/**
23+
* @var ScopeConfigInterface
24+
*/
25+
private ScopeConfigInterface $scopeConfig;
26+
27+
/**
28+
* @var string
29+
*/
30+
private string $storeId;
31+
32+
public function setUp(): void
33+
{
34+
$objectManager = Bootstrap::getObjectManager();
35+
$this->scopeConfig = $objectManager->get(ScopeConfigInterface::class);
36+
/* @var StoreResolverInterface $storeResolver */
37+
$storeResolver = $objectManager->get(StoreResolverInterface::class);
38+
$this->storeId = $storeResolver->getCurrentStoreId();
39+
}
40+
1741
/**
1842
* @magentoApiDataFixture Magento/Customer/_files/customer.php
1943
*/
@@ -31,7 +55,16 @@ public function testEmailNotAvailable()
3155

3256
self::assertArrayHasKey('isEmailAvailable', $response);
3357
self::assertArrayHasKey('is_email_available', $response['isEmailAvailable']);
34-
self::assertFalse($response['isEmailAvailable']['is_email_available']);
58+
$emailConfig = $this->scopeConfig->getValue(
59+
AccountManagement::GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG,
60+
ScopeInterface::SCOPE_STORE,
61+
$this->storeId
62+
);
63+
if (!$emailConfig) {
64+
self::assertTrue($response['isEmailAvailable']['is_email_available']);
65+
} else {
66+
self::assertFalse($response['isEmailAvailable']['is_email_available']);
67+
}
3568
}
3669

3770
/**

Diff for: dev/tests/api-functional/testsuite/Magento/GraphQl/Newsletter/Customer/SubscribeEmailToNewsletterTest.php

+19-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
namespace Magento\GraphQl\Newsletter\Customer;
99

1010
use Exception;
11+
use Magento\Customer\Model\AccountManagement;
1112
use Magento\Customer\Model\CustomerAuthUpdate;
1213
use Magento\Customer\Model\CustomerRegistry;
14+
use Magento\Framework\App\Config\ScopeConfigInterface;
1315
use Magento\Framework\Exception\AuthenticationException;
1416
use Magento\Integration\Api\CustomerTokenServiceInterface;
1517
use Magento\Newsletter\Model\ResourceModel\Subscriber as SubscriberResourceModel;
18+
use Magento\Store\Model\ScopeInterface;
1619
use Magento\TestFramework\Helper\Bootstrap;
1720
use Magento\TestFramework\TestCase\GraphQlAbstract;
1821

@@ -40,13 +43,18 @@ class SubscribeEmailToNewsletterTest extends GraphQlAbstract
4043
* @var SubscriberResourceModel
4144
*/
4245
private $subscriberResource;
46+
/**
47+
* @var ScopeConfigInterface
48+
*/
49+
private $scopeConfig;
4350

4451
/**
4552
* @inheritDoc
4653
*/
4754
protected function setUp(): void
4855
{
4956
$objectManager = Bootstrap::getObjectManager();
57+
$this->scopeConfig = $objectManager->get(ScopeConfigInterface::class);
5058
$this->customerAuthUpdate = Bootstrap::getObjectManager()->get(CustomerAuthUpdate::class);
5159
$this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class);
5260
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
@@ -146,10 +154,17 @@ public function testNewsletterSubscriptionWithAnotherCustomerEmail()
146154
{
147155
$query = $this->getQuery('[email protected]');
148156

149-
$this->expectException(Exception::class);
150-
$this->expectExceptionMessage('Cannot create a newsletter subscription.' . "\n");
151-
152-
$this->graphQlMutation($query, [], '', $this->getHeaderMap('[email protected]'));
157+
$guestLoginConfig = $this->scopeConfig->getValue(
158+
AccountManagement::GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG,
159+
ScopeInterface::SCOPE_WEBSITE,
160+
1
161+
);
162+
163+
if ($guestLoginConfig) {
164+
$this->expectException(Exception::class);
165+
$this->expectExceptionMessage('Cannot create a newsletter subscription.' . "\n");
166+
$this->graphQlMutation($query, [], '', $this->getHeaderMap('[email protected]'));
167+
}
153168
}
154169

155170
/**

0 commit comments

Comments
 (0)