-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5381 from magento-tsg/2.4-develop-pr13
[TSG] Fixes for 2.4 (pr13) (2.4-develop)
- Loading branch information
Showing
30 changed files
with
887 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckDoubleImportOfProductsTest.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Newsletter\Controller\Ajax; | ||
|
||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Action\HttpGetActionInterface; | ||
use Magento\Framework\Controller\Result\Json; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Validator\EmailAddress as EmailAddressValidator; | ||
use Magento\Newsletter\Model\GuestSubscriptionChecker; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Newsletter subscription status verification controller. | ||
*/ | ||
class Status extends Action implements HttpGetActionInterface | ||
{ | ||
/** | ||
* @var EmailAddressValidator | ||
*/ | ||
private $emailAddressValidator; | ||
|
||
/** | ||
* @var GuestSubscriptionChecker | ||
*/ | ||
private $guestSubscriptionChecker; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @param Context $context | ||
* @param EmailAddressValidator $emailAddressValidator | ||
* @param GuestSubscriptionChecker $guestSubscriptionChecker | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
EmailAddressValidator $emailAddressValidator, | ||
GuestSubscriptionChecker $guestSubscriptionChecker, | ||
LoggerInterface $logger | ||
) { | ||
parent::__construct($context); | ||
$this->emailAddressValidator = $emailAddressValidator; | ||
$this->guestSubscriptionChecker = $guestSubscriptionChecker; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute() | ||
{ | ||
$email = (string)$this->getRequest()->getParam('email'); | ||
|
||
$response = [ | ||
'subscribed' => false, | ||
'errors' => false, | ||
]; | ||
try { | ||
if (!empty($email) && $this->emailAddressValidator->isValid($email)) { | ||
$response['subscribed'] = $this->guestSubscriptionChecker->isSubscribed($email); | ||
} | ||
} catch (LocalizedException | \DomainException $exception) { | ||
$this->logger->error($exception->getMessage()); | ||
$response['errors'] = true; | ||
} | ||
|
||
/** @var Json $resultJson */ | ||
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); | ||
|
||
return $resultJson->setData($response); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/code/Magento/Newsletter/Model/GuestSubscriptionChecker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Newsletter\Model; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
/** | ||
* Checks guest subscription by email. | ||
*/ | ||
class GuestSubscriptionChecker | ||
{ | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @param ResourceConnection $resourceConnection | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct(ResourceConnection $resourceConnection, StoreManagerInterface $storeManager) | ||
{ | ||
$this->resourceConnection = $resourceConnection; | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* Check is subscribed by email | ||
* | ||
* @param string $subscriberEmail | ||
* @return bool | ||
*/ | ||
public function isSubscribed(string $subscriberEmail): bool | ||
{ | ||
if (!empty($subscriberEmail)) { | ||
$storeIds = $this->storeManager->getWebsite()->getStoreIds(); | ||
$connection = $this->resourceConnection->getConnection(); | ||
$select = $connection | ||
->select() | ||
->from($this->resourceConnection->getTableName('newsletter_subscriber')) | ||
->where('subscriber_email = ?', $subscriberEmail) | ||
->where('store_id IN (?)', $storeIds) | ||
->where('customer_id = 0') | ||
->limit(1); | ||
|
||
return (bool)$connection->fetchOne($select); | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/code/Magento/Newsletter/view/frontend/layout/customer_account_create.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceBlock name="customer_form_register"> | ||
<block name="customer.form.register.newsletter" template="Magento_Newsletter::form/register/newsletter.phtml"/> | ||
</referenceBlock> | ||
</body> | ||
</page> |
13 changes: 13 additions & 0 deletions
13
app/code/Magento/Newsletter/view/frontend/requirejs-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
var config = { | ||
map: { | ||
'*': { | ||
subscriptionStatusResolver: 'Magento_Newsletter/js/subscription-status-resolver', | ||
newsletterSignUp: 'Magento_Newsletter/js/newsletter-sign-up' | ||
} | ||
} | ||
}; |
Oops, something went wrong.