Skip to content

Commit 2b06983

Browse files
author
Oleksii Korshenko
committed
MAGETWO-87153: [EngCom Team] Batch 13. Forwardports to 2.3-develop #1298
- Merge Pull Request magento-engcom/magento2ce#1298 from magento-engcom-team/magento2:batch-13-forwardport-2.3-develop - Merged commits: 1. 54301a8 2. 402b719 3. 3837f27 4. 031e23e 5. aa267f4 6. 934818d 7. 6bed7d4 8. 72b2794 9. 4e64c41 10. d3feb28 11. 7aeccea 12. b857c02 13. a75bf23 14. ab2e579 15. d904690 16. a821c7a 17. 68ac4c0 18. 93fe4d1 19. f43fd4b 20. 2c52a8f
2 parents c7207f6 + 2c52a8f commit 2b06983

File tree

25 files changed

+680
-191
lines changed

25 files changed

+680
-191
lines changed

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ define([
9797
success: function (res) {
9898
var eventData, parameters;
9999

100-
$(document).trigger('ajax:addToCart', form.data().productSku);
100+
$(document).trigger('ajax:addToCart', form.data().productSku, form, res);
101101

102102
if (self.isLoaderEnabled()) {
103103
$('body').trigger(self.options.processStop);

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier;
77

8+
use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
89
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
910
use Magento\Ui\Component\Container;
1011
use Magento\Ui\Component\Form;
@@ -466,7 +467,17 @@ protected function getRows()
466467
[],
467468
['dataScope' => 'product_link']
468469
),
469-
'sku_container' => $this->getColumn('sku', __('SKU')),
470+
'sku_container' => $this->getColumn(
471+
'sku',
472+
__('SKU'),
473+
[
474+
'validation' =>
475+
[
476+
'required-entry' => true,
477+
'max_text_length' => Sku::SKU_MAX_LENGTH,
478+
]
479+
]
480+
),
470481
'price_container' => $this->getColumn(
471482
'price',
472483
__('Price'),

app/code/Magento/Customer/Controller/Account/Confirmation.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
*/
77
namespace Magento\Customer\Controller\Account;
88

9+
use Magento\Customer\Model\Url;
910
use Magento\Framework\App\Action\Context;
1011
use Magento\Customer\Model\Session;
12+
use Magento\Framework\App\ObjectManager;
1113
use Magento\Framework\View\Result\PageFactory;
1214
use Magento\Store\Model\StoreManagerInterface;
1315
use Magento\Customer\Api\AccountManagementInterface;
@@ -35,24 +37,32 @@ class Confirmation extends \Magento\Customer\Controller\AbstractAccount
3537
*/
3638
protected $resultPageFactory;
3739

40+
/**
41+
* @var Url
42+
*/
43+
private $customerUrl;
44+
3845
/**
3946
* @param Context $context
4047
* @param Session $customerSession
4148
* @param PageFactory $resultPageFactory
4249
* @param StoreManagerInterface $storeManager
4350
* @param AccountManagementInterface $customerAccountManagement
51+
* @param Url $customerUrl
4452
*/
4553
public function __construct(
4654
Context $context,
4755
Session $customerSession,
4856
PageFactory $resultPageFactory,
4957
StoreManagerInterface $storeManager,
50-
AccountManagementInterface $customerAccountManagement
58+
AccountManagementInterface $customerAccountManagement,
59+
Url $customerUrl = null
5160
) {
5261
$this->session = $customerSession;
5362
$this->resultPageFactory = $resultPageFactory;
5463
$this->storeManager = $storeManager;
5564
$this->customerAccountManagement = $customerAccountManagement;
65+
$this->customerUrl = $customerUrl ?: ObjectManager::getInstance()->get(Url::class);
5666
parent::__construct($context);
5767
}
5868

@@ -98,6 +108,8 @@ public function execute()
98108
$resultPage = $this->resultPageFactory->create();
99109
$resultPage->getLayout()->getBlock('accountConfirmation')->setEmail(
100110
$this->getRequest()->getParam('email', $email)
111+
)->setLoginUrl(
112+
$this->customerUrl->getLoginUrl()
101113
);
102114
return $resultPage;
103115
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model;
7+
8+
use Magento\Store\Model\ScopeInterface;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\Registry;
11+
12+
/**
13+
* Class AccountConfirmation.
14+
* Checks if email confirmation required for customer.
15+
*/
16+
class AccountConfirmation
17+
{
18+
/**
19+
* Configuration path for email confirmation.
20+
*/
21+
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
22+
23+
/**
24+
* @var ScopeConfigInterface
25+
*/
26+
private $scopeConfig;
27+
28+
/**
29+
* @var Registry
30+
*/
31+
private $registry;
32+
33+
/**
34+
* @param ScopeConfigInterface $scopeConfig
35+
* @param Registry $registry
36+
*/
37+
public function __construct(
38+
ScopeConfigInterface $scopeConfig,
39+
Registry $registry
40+
) {
41+
$this->scopeConfig = $scopeConfig;
42+
$this->registry = $registry;
43+
}
44+
45+
/**
46+
* Check if accounts confirmation is required.
47+
*
48+
* @param int|null $websiteId
49+
* @param int|null $customerId
50+
* @param string $customerEmail
51+
* @return bool
52+
*/
53+
public function isConfirmationRequired($websiteId, $customerId, $customerEmail): bool
54+
{
55+
if ($this->canSkipConfirmation($customerId, $customerEmail)) {
56+
return false;
57+
}
58+
59+
return (bool)$this->scopeConfig->getValue(
60+
self::XML_PATH_IS_CONFIRM,
61+
ScopeInterface::SCOPE_WEBSITES,
62+
$websiteId
63+
);
64+
}
65+
66+
/**
67+
* Check whether confirmation may be skipped when registering using certain email address.
68+
*
69+
* @param int|null $customerId
70+
* @param string $customerEmail
71+
* @return bool
72+
*/
73+
private function canSkipConfirmation($customerId, $customerEmail): bool
74+
{
75+
if (!$customerId) {
76+
return false;
77+
}
78+
79+
/* If an email was used to start the registration process and it is the same email as the one
80+
used to register, then this can skip confirmation.
81+
*/
82+
$skipConfirmationIfEmail = $this->registry->registry("skip_confirmation_if_email");
83+
if (!$skipConfirmationIfEmail) {
84+
return false;
85+
}
86+
87+
return strtolower($skipConfirmationIfEmail) === strtolower($customerEmail);
88+
}
89+
}

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class AccountManagement implements AccountManagementInterface
8989
*/
9090
const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity';
9191

92+
/**
93+
* @deprecated
94+
* @see AccountConfirmation::XML_PATH_IS_CONFIRM
95+
*/
9296
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
9397

9498
/**
@@ -298,6 +302,11 @@ class AccountManagement implements AccountManagementInterface
298302
*/
299303
private $dateTimeFactory;
300304

305+
/**
306+
* @var AccountConfirmation
307+
*/
308+
private $accountConfirmation;
309+
301310
/**
302311
* @param CustomerFactory $customerFactory
303312
* @param ManagerInterface $eventManager
@@ -323,7 +332,8 @@ class AccountManagement implements AccountManagementInterface
323332
* @param ObjectFactory $objectFactory
324333
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
325334
* @param CredentialsValidator|null $credentialsValidator
326-
* @param DateTimeFactory $dateTimeFactory
335+
* @param DateTimeFactory|null $dateTimeFactory
336+
* @param AccountConfirmation|null $accountConfirmation
327337
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
328338
*/
329339
public function __construct(
@@ -351,7 +361,8 @@ public function __construct(
351361
ObjectFactory $objectFactory,
352362
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
353363
CredentialsValidator $credentialsValidator = null,
354-
DateTimeFactory $dateTimeFactory = null
364+
DateTimeFactory $dateTimeFactory = null,
365+
AccountConfirmation $accountConfirmation = null
355366
) {
356367
$this->customerFactory = $customerFactory;
357368
$this->eventManager = $eventManager;
@@ -379,6 +390,8 @@ public function __construct(
379390
$this->credentialsValidator =
380391
$credentialsValidator ?: ObjectManager::getInstance()->get(CredentialsValidator::class);
381392
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
393+
$this->accountConfirmation = $accountConfirmation ?: ObjectManager::getInstance()
394+
->get(AccountConfirmation::class);
382395
}
383396

384397
/**
@@ -1161,17 +1174,15 @@ protected function sendEmailTemplate(
11611174
*
11621175
* @param CustomerInterface $customer
11631176
* @return bool
1177+
* @deprecated
1178+
* @see AccountConfirmation::isConfirmationRequired
11641179
*/
11651180
protected function isConfirmationRequired($customer)
11661181
{
1167-
if ($this->canSkipConfirmation($customer)) {
1168-
return false;
1169-
}
1170-
1171-
return (bool)$this->scopeConfig->getValue(
1172-
self::XML_PATH_IS_CONFIRM,
1173-
ScopeInterface::SCOPE_WEBSITES,
1174-
$customer->getWebsiteId()
1182+
return $this->accountConfirmation->isConfirmationRequired(
1183+
$customer->getWebsiteId(),
1184+
$customer->getId(),
1185+
$customer->getEmail()
11751186
);
11761187
}
11771188

@@ -1180,6 +1191,8 @@ protected function isConfirmationRequired($customer)
11801191
*
11811192
* @param CustomerInterface $customer
11821193
* @return bool
1194+
* @deprecated
1195+
* @see AccountConfirmation::isConfirmationRequired
11831196
*/
11841197
protected function canSkipConfirmation($customer)
11851198
{

app/code/Magento/Customer/Model/Customer.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\Framework\Indexer\StateInterface;
1919
use Magento\Framework\Reflection\DataObjectProcessor;
2020
use Magento\Store\Model\ScopeInterface;
21+
use Magento\Framework\App\ObjectManager;
2122

2223
/**
2324
* Customer model
@@ -58,6 +59,10 @@ class Customer extends \Magento\Framework\Model\AbstractModel
5859

5960
const XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template';
6061

62+
/**
63+
* @deprecated
64+
* @see AccountConfirmation::XML_PATH_IS_CONFIRM
65+
*/
6166
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
6267

6368
const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
@@ -208,6 +213,11 @@ class Customer extends \Magento\Framework\Model\AbstractModel
208213
*/
209214
protected $indexerRegistry;
210215

216+
/**
217+
* @var AccountConfirmation
218+
*/
219+
private $accountConfirmation;
220+
211221
/**
212222
* @param \Magento\Framework\Model\Context $context
213223
* @param \Magento\Framework\Registry $registry
@@ -229,6 +239,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel
229239
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
230240
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
231241
* @param array $data
242+
* @param AccountConfirmation|null $accountConfirmation
232243
*
233244
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
234245
*/
@@ -252,7 +263,8 @@ public function __construct(
252263
\Magento\Customer\Api\CustomerMetadataInterface $metadataService,
253264
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
254265
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
255-
array $data = []
266+
array $data = [],
267+
AccountConfirmation $accountConfirmation = null
256268
) {
257269
$this->metadataService = $metadataService;
258270
$this->_scopeConfig = $scopeConfig;
@@ -269,6 +281,8 @@ public function __construct(
269281
$this->dataObjectProcessor = $dataObjectProcessor;
270282
$this->dataObjectHelper = $dataObjectHelper;
271283
$this->indexerRegistry = $indexerRegistry;
284+
$this->accountConfirmation = $accountConfirmation ?: ObjectManager::getInstance()
285+
->get(AccountConfirmation::class);
272286
parent::__construct(
273287
$context,
274288
$registry,
@@ -770,20 +784,14 @@ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeI
770784
* Check if accounts confirmation is required in config
771785
*
772786
* @return bool
787+
* @deprecated
788+
* @see AccountConfirmation::isConfirmationRequired
773789
*/
774790
public function isConfirmationRequired()
775791
{
776-
if ($this->canSkipConfirmation()) {
777-
return false;
778-
}
779-
780792
$websiteId = $this->getWebsiteId() ? $this->getWebsiteId() : null;
781793

782-
return (bool)$this->_scopeConfig->getValue(
783-
self::XML_PATH_IS_CONFIRM,
784-
ScopeInterface::SCOPE_WEBSITES,
785-
$websiteId
786-
);
794+
return $this->accountConfirmation->isConfirmationRequired($websiteId, $this->getId(), $this->getEmail());
787795
}
788796

789797
/**
@@ -1156,6 +1164,8 @@ public function setIsReadonly($value)
11561164
* Check whether confirmation may be skipped when registering using certain email address
11571165
*
11581166
* @return bool
1167+
* @deprecated
1168+
* @see AccountConfirmation::isConfirmationRequired
11591169
*/
11601170
protected function canSkipConfirmation()
11611171
{

0 commit comments

Comments
 (0)