-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.4-develop' into 2.3-develop
# Conflicts: # Block/Script.php # Controller/Adminhtml/Smtp/Sync/Customer.php # Controller/Adminhtml/Smtp/Sync/EstimateCustomer.php # Controller/Adminhtml/Smtp/TestConnection.php # Helper/EmailMarketing.php # Observer/Customer/SubscriberSaveCommitAfter.php # Observer/Order/OrderComplete.php # Observer/Order/OrderCreate.php # Observer/Order/ShipmentCreate.php # Observer/Quote/DeleteQuote.php # Observer/Quote/SyncQuote.php # Setup/UpgradeData.php # composer.json # etc/adminhtml/menu.xml # i18n/en_US.csv
- Loading branch information
Showing
36 changed files
with
1,504 additions
and
675 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
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
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,90 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Smtp | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\Smtp\Block\Adminhtml\System\Config; | ||
|
||
/** | ||
* Class SyncOrder | ||
* @package Mageplaza\Smtp\Block\Adminhtml\System\Config | ||
*/ | ||
class SyncOrder extends Button | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'system/config/sync-template.phtml'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEstimateUrl() | ||
{ | ||
return $this->getUrl('adminhtml/smtp_sync/estimateorder', ['_current' => true]); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getWebsiteId() | ||
{ | ||
return $this->getRequest()->getParam('website'); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getStoreId() | ||
{ | ||
return $this->getRequest()->getParam('store'); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getSyncSuccessMessage() | ||
{ | ||
return __('Order synchronization has been completed.'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getElementId() | ||
{ | ||
return 'mp-sync-order'; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getComponent() | ||
{ | ||
return 'Mageplaza_Smtp/js/sync/order'; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isRenderCss() | ||
{ | ||
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
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,119 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Smtp | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\Smtp\Controller\Adminhtml\Smtp\Sync; | ||
|
||
use Exception; | ||
use Magento\Backend\App\Action; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\App\ResponseInterface; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Mageplaza\Smtp\Helper\EmailMarketing; | ||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Class AbstractEstimate | ||
* @package Mageplaza\Smtp\Controller\Adminhtml\Smtp\Sync | ||
*/ | ||
abstract class AbstractEstimate extends Action | ||
{ | ||
/** | ||
* Authorization level of a basic admin session | ||
* | ||
* @see _isAllowed() | ||
*/ | ||
const ADMIN_RESOURCE = 'Mageplaza_Smtp::email_marketing'; | ||
|
||
/** | ||
* @var EmailMarketing | ||
*/ | ||
protected $emailMarketing; | ||
|
||
/** | ||
* AbstractEstimate constructor. | ||
* | ||
* @param Context $context | ||
* @param EmailMarketing $emailMarketing | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
EmailMarketing $emailMarketing | ||
) { | ||
$this->emailMarketing = $emailMarketing; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @return ResponseInterface|ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
try { | ||
|
||
if (!$this->emailMarketing->getAppID() || !$this->emailMarketing->getSecretKey()) { | ||
throw new LocalizedException(__('App ID or Secret Key is empty')); | ||
} | ||
|
||
$collection = $this->prepareCollection(); | ||
$storeId = $this->getRequest()->getParam('storeId'); | ||
$websiteId = $this->getRequest()->getParam('websiteId'); | ||
if ($storeId) { | ||
$collection->addFieldToFilter('store_id', $storeId); | ||
} | ||
|
||
if ($websiteId) { | ||
$collection->addFieldToFilter('website_id', $websiteId); | ||
} | ||
|
||
$ids = $collection->getAllIds(); | ||
|
||
$result['ids'] = $ids; | ||
$result['total'] = count($ids); | ||
|
||
if ($result['total'] === 0) { | ||
$result['message'] = $this->getZeroMessage(); | ||
} | ||
|
||
$result['status'] = true; | ||
|
||
} catch (Exception $e) { | ||
$result = [ | ||
'status' => false, | ||
'message' => $e->getMessage() | ||
]; | ||
} | ||
|
||
return $this->getResponse()->representJson(EmailMarketing::jsonEncode($result)); | ||
} | ||
|
||
/** | ||
* @return AbstractCollection | ||
*/ | ||
abstract public function prepareCollection(); | ||
|
||
/** | ||
* @return Phrase | ||
*/ | ||
abstract public function getZeroMessage(); | ||
} |
Oops, something went wrong.