Skip to content

Commit 73c7ac2

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1635 from magento-engcom/2.2-develop-prs
Public Pull Requests #11607 [Backport 2.2-develop] Fix AcountManagementTest unit test fail randomly by @adrian-martinez-interactiv4 #11757 Fix #11729 - negative value in excel export [M2.2] by @hauso #11410 "Ignore this notification" isn't working by @crissanclick #11610 FR#6891_22 Add-to-cart checkbox still visible when = false by @mrodespin Fixed Public Issues #11729 Exported Excel with negative number can't be opened by MS Office #11365 "Ignore this notification" isn't working #6891 Add-to-cart checkbox still visible when $canItemsAddToCart = false
2 parents 24c5815 + cb1c75d commit 73c7ac2

File tree

6 files changed

+111
-54
lines changed

6 files changed

+111
-54
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ switch ($type = $block->getType()) {
203203
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
204204
<?php endif; ?>
205205

206-
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
206+
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
207207
<?php if (!$_item->getRequiredOptions()): ?>
208208
<div class="field choice related">
209209
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />

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

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
use Magento\Customer\Api\Data\AddressInterface;
1313
use Magento\Customer\Api\Data\CustomerInterface;
1414
use Magento\Customer\Api\Data\ValidationResultsInterfaceFactory;
15-
use Magento\Customer\Model\EmailNotificationInterface;
1615
use Magento\Customer\Helper\View as CustomerViewHelper;
1716
use Magento\Customer\Model\Config\Share as ConfigShare;
1817
use Magento\Customer\Model\Customer as CustomerModel;
18+
use Magento\Customer\Model\Customer\CredentialsValidator;
1919
use Magento\Customer\Model\Metadata\Validator;
2020
use Magento\Eav\Model\Validator\Attribute\Backend;
2121
use Magento\Framework\Api\ExtensibleDataObjectConverter;
2222
use Magento\Framework\App\Area;
2323
use Magento\Framework\App\Config\ScopeConfigInterface;
2424
use Magento\Framework\App\ObjectManager;
25+
use Magento\Framework\DataObjectFactory as ObjectFactory;
2526
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
2627
use Magento\Framework\Encryption\Helper\Security;
2728
use Magento\Framework\Event\ManagerInterface;
@@ -30,23 +31,22 @@
3031
use Magento\Framework\Exception\InputException;
3132
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
3233
use Magento\Framework\Exception\LocalizedException;
34+
use Magento\Framework\Exception\MailException;
3335
use Magento\Framework\Exception\NoSuchEntityException;
3436
use Magento\Framework\Exception\State\ExpiredException;
3537
use Magento\Framework\Exception\State\InputMismatchException;
3638
use Magento\Framework\Exception\State\InvalidTransitionException;
37-
use Magento\Framework\DataObjectFactory as ObjectFactory;
3839
use Magento\Framework\Exception\State\UserLockedException;
39-
use Magento\Framework\Registry;
40-
use Magento\Store\Model\ScopeInterface;
41-
use Psr\Log\LoggerInterface as PsrLogger;
42-
use Magento\Framework\Exception\MailException;
40+
use Magento\Framework\Intl\DateTimeFactory;
4341
use Magento\Framework\Mail\Template\TransportBuilder;
4442
use Magento\Framework\Math\Random;
4543
use Magento\Framework\Reflection\DataObjectProcessor;
44+
use Magento\Framework\Registry;
4645
use Magento\Framework\Stdlib\DateTime;
4746
use Magento\Framework\Stdlib\StringUtils as StringHelper;
47+
use Magento\Store\Model\ScopeInterface;
4848
use Magento\Store\Model\StoreManagerInterface;
49-
use Magento\Customer\Model\Customer\CredentialsValidator;
49+
use Psr\Log\LoggerInterface as PsrLogger;
5050

5151
/**
5252
* Handle various customer account actions
@@ -293,6 +293,11 @@ class AccountManagement implements AccountManagementInterface
293293
*/
294294
private $credentialsValidator;
295295

296+
/**
297+
* @var DateTimeFactory
298+
*/
299+
private $dateTimeFactory;
300+
296301
/**
297302
* @param CustomerFactory $customerFactory
298303
* @param ManagerInterface $eventManager
@@ -318,6 +323,7 @@ class AccountManagement implements AccountManagementInterface
318323
* @param ObjectFactory $objectFactory
319324
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
320325
* @param CredentialsValidator|null $credentialsValidator
326+
* @param DateTimeFactory $dateTimeFactory
321327
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
322328
*/
323329
public function __construct(
@@ -344,7 +350,8 @@ public function __construct(
344350
CustomerModel $customerModel,
345351
ObjectFactory $objectFactory,
346352
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
347-
CredentialsValidator $credentialsValidator = null
353+
CredentialsValidator $credentialsValidator = null,
354+
DateTimeFactory $dateTimeFactory = null
348355
) {
349356
$this->customerFactory = $customerFactory;
350357
$this->eventManager = $eventManager;
@@ -369,8 +376,9 @@ public function __construct(
369376
$this->customerModel = $customerModel;
370377
$this->objectFactory = $objectFactory;
371378
$this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
372-
$this->credentialsValidator = $credentialsValidator ?: ObjectManager::getInstance()
373-
->get(CredentialsValidator::class);
379+
$this->credentialsValidator =
380+
$credentialsValidator ?: ObjectManager::getInstance()->get(CredentialsValidator::class);
381+
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
374382
}
375383

376384
/**
@@ -380,7 +388,6 @@ public function __construct(
380388
*/
381389
private function getAuthentication()
382390
{
383-
384391
if (!($this->authentication instanceof AuthenticationInterface)) {
385392
return \Magento\Framework\App\ObjectManager::getInstance()->get(
386393
\Magento\Customer\Model\AuthenticationInterface::class
@@ -613,16 +620,16 @@ protected function makeRequiredCharactersCheck($password)
613620
$return = 0;
614621

615622
if (preg_match('/[0-9]+/', $password)) {
616-
$counter ++;
623+
$counter++;
617624
}
618625
if (preg_match('/[A-Z]+/', $password)) {
619-
$counter ++;
626+
$counter++;
620627
}
621628
if (preg_match('/[a-z]+/', $password)) {
622-
$counter ++;
629+
$counter++;
623630
}
624631
if (preg_match('/[^a-zA-Z0-9]+/', $password)) {
625-
$counter ++;
632+
$counter++;
626633
}
627634

628635
if ($counter < $requiredNumber) {
@@ -890,16 +897,14 @@ public function validate(CustomerInterface $customer)
890897

891898
$result = $this->getEavValidator()->isValid($customerModel);
892899
if ($result === false && is_array($this->getEavValidator()->getMessages())) {
893-
return $validationResults->setIsValid(false)
894-
->setMessages(
895-
call_user_func_array(
896-
'array_merge',
897-
$this->getEavValidator()->getMessages()
898-
)
899-
);
900+
return $validationResults->setIsValid(false)->setMessages(
901+
call_user_func_array(
902+
'array_merge',
903+
$this->getEavValidator()->getMessages()
904+
)
905+
);
900906
}
901-
return $validationResults->setIsValid(true)
902-
->setMessages([]);
907+
return $validationResults->setIsValid(true)->setMessages([]);
903908
}
904909

905910
/**
@@ -949,10 +954,12 @@ public function isCustomerInStore($customerWebsiteId, $storeId)
949954
private function validateResetPasswordToken($customerId, $resetPasswordLinkToken)
950955
{
951956
if (empty($customerId) || $customerId < 0) {
952-
throw new InputException(__(
953-
'Invalid value of "%value" provided for the %fieldName field.',
954-
['value' => $customerId, 'fieldName' => 'customerId']
955-
));
957+
throw new InputException(
958+
__(
959+
'Invalid value of "%value" provided for the %fieldName field.',
960+
['value' => $customerId, 'fieldName' => 'customerId']
961+
)
962+
);
956963
}
957964
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
958965
$params = ['fieldName' => 'resetPasswordLinkToken'];
@@ -1076,10 +1083,10 @@ protected function getTemplateTypes()
10761083
* self::NEW_ACCOUNT_EMAIL_CONFIRMATION email with confirmation link
10771084
*/
10781085
$types = [
1079-
self::NEW_ACCOUNT_EMAIL_REGISTERED => self::XML_PATH_REGISTER_EMAIL_TEMPLATE,
1086+
self::NEW_ACCOUNT_EMAIL_REGISTERED => self::XML_PATH_REGISTER_EMAIL_TEMPLATE,
10801087
self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD => self::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE,
1081-
self::NEW_ACCOUNT_EMAIL_CONFIRMED => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE,
1082-
self::NEW_ACCOUNT_EMAIL_CONFIRMATION => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
1088+
self::NEW_ACCOUNT_EMAIL_CONFIRMED => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE,
1089+
self::NEW_ACCOUNT_EMAIL_CONFIRMATION => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
10831090
];
10841091
return $types;
10851092
}
@@ -1109,12 +1116,11 @@ protected function sendEmailTemplate(
11091116
$email = $customer->getEmail();
11101117
}
11111118

1112-
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
1113-
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
1114-
->setTemplateVars($templateParams)
1115-
->setFrom($this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId))
1116-
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
1117-
->getTransport();
1119+
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(
1120+
['area' => Area::AREA_FRONTEND, 'store' => $storeId]
1121+
)->setTemplateVars($templateParams)->setFrom(
1122+
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
1123+
)->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();
11181124

11191125
$transport->sendMessage();
11201126

@@ -1178,8 +1184,8 @@ public function isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)
11781184

11791185
$expirationPeriod = $this->customerModel->getResetPasswordLinkExpirationPeriod();
11801186

1181-
$currentTimestamp = (new \DateTime())->getTimestamp();
1182-
$tokenTimestamp = (new \DateTime($rpTokenCreatedAt))->getTimestamp();
1187+
$currentTimestamp = $this->dateTimeFactory->create()->getTimestamp();
1188+
$tokenTimestamp = $this->dateTimeFactory->create($rpTokenCreatedAt)->getTimestamp();
11831189
if ($tokenTimestamp > $currentTimestamp) {
11841190
return true;
11851191
}
@@ -1215,7 +1221,9 @@ public function changeResetPasswordLinkToken($customer, $passwordLinkToken)
12151221
if (is_string($passwordLinkToken) && !empty($passwordLinkToken)) {
12161222
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
12171223
$customerSecure->setRpToken($passwordLinkToken);
1218-
$customerSecure->setRpTokenCreatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
1224+
$customerSecure->setRpTokenCreatedAt(
1225+
$this->dateTimeFactory->create()->format(DateTime::DATETIME_PHP_FORMAT)
1226+
);
12191227
$this->customerRepository->save($customer);
12201228
}
12211229
return true;
@@ -1304,8 +1312,8 @@ protected function getFullCustomerObject($customer)
13041312
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
13051313
// object passed for events
13061314
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
1307-
$customerData = $this->dataProcessor
1308-
->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
1315+
$customerData =
1316+
$this->dataProcessor->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
13091317
$mergedCustomerData->addData($customerData);
13101318
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
13111319
return $mergedCustomerData;

0 commit comments

Comments
 (0)