-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a button in the admin to no retry when truncate the errors table #…
…1498 for magento 2.3
- Loading branch information
1 parent
9ea9a82
commit c5dac4d
Showing
6 changed files
with
211 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* mc-magento2 Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento2 | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @date: 2/20/17 3:25 PM | ||
* @file: ResetErrors.php | ||
*/ | ||
|
||
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; | ||
|
||
class ResetErrorsNoRetry extends \Magento\Config\Block\System\Config\Form\Field | ||
{ | ||
/** | ||
* @var \Ebizmarts\MailChimp\Helper\Data | ||
*/ | ||
private $_helper; | ||
|
||
/** | ||
* ResetErrors constructor. | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Ebizmarts\MailChimp\Helper\Data $helper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Ebizmarts\MailChimp\Helper\Data $helper, | ||
array $data = [] | ||
) { | ||
|
||
$this->_helper = $helper; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
$this->setTemplate('system/config/reseterrorsnoretry.phtml'); | ||
} | ||
|
||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$originalData = $element->getOriginalData(); | ||
$this->addData( | ||
[ | ||
'button_label' => __($originalData['button_label']), | ||
'button_url' => $this->getAjaxCheckUrl(), | ||
'html_id' => $element->getHtmlId(), | ||
] | ||
); | ||
return $this->_toHtml(); | ||
} | ||
|
||
public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$originalData = $element->getOriginalData(); | ||
$label = $originalData['button_label']; | ||
$this->addData([ | ||
'button_label' => __($label), | ||
'button_url' => $this->getAjaxCheckUrl(), | ||
'html_id' => $element->getHtmlId(), | ||
]); | ||
return $this->_toHtml(); | ||
} | ||
public function getAjaxCheckUrl() | ||
{ | ||
$params = $this->getRequest()->getParams(); | ||
$scope = []; | ||
if (isset($params['website'])) { | ||
$scope = ['website'=>$params['website']]; | ||
} elseif (isset($params['store'])) { | ||
$scope = ['store'=>$params['store']]; | ||
} | ||
return $this->_urlBuilder->getUrl('mailchimp/ecommerce/ResetLocalErrorsNoRetry', $scope); | ||
} | ||
} |
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
95 changes: 95 additions & 0 deletions
95
Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.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,95 @@ | ||
<?php | ||
/** | ||
* mc-magento2 Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento2 | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @date: 2/21/17 5:07 PM | ||
* @file: ResetLocalErrors.php | ||
*/ | ||
|
||
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Ecommerce; | ||
|
||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Exception\ValidatorException; | ||
use Symfony\Component\Config\Definition\Exception\Exception; | ||
|
||
class ResetLocalErrorsNoRetry extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $resultJsonFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Helper\Data | ||
*/ | ||
protected $helper; | ||
/** | ||
* @var \Magento\Store\Model\StoreManagerInterface | ||
*/ | ||
protected $storeManager; | ||
|
||
/** | ||
* ResetLocalErrors constructor. | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface | ||
* @param \Ebizmarts\MailChimp\Helper\Data $helper | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
JsonFactory $resultJsonFactory, | ||
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface, | ||
\Ebizmarts\MailChimp\Helper\Data $helper | ||
) { | ||
|
||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->helper = $helper; | ||
$this->storeManager = $storeManagerInterface; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$valid = 1; | ||
$message = ''; | ||
$params = $this->getRequest()->getParams(); | ||
if (isset($params['website'])) { | ||
$mailchimpStore = $this->helper->getConfigValue( | ||
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, | ||
$params['website'], | ||
'website' | ||
); | ||
} elseif (isset($params['store'])) { | ||
$mailchimpStore = $this->helper->getConfigValue( | ||
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, | ||
$params['store'], | ||
'store' | ||
); | ||
} else { | ||
$mailchimpStore = $this->helper->getConfigValue( | ||
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, | ||
$this->storeManager->getStore() | ||
); | ||
} | ||
|
||
$resultJson = $this->resultJsonFactory->create(); | ||
try { | ||
$this->helper->resetErrors($mailchimpStore, false); | ||
} catch (ValidatorException $e) { | ||
$valid = 0; | ||
$message = $e->getMessage(); | ||
} | ||
return $resultJson->setData([ | ||
'valid' => (int)$valid, | ||
'message' => $message, | ||
]); | ||
} | ||
protected function _isAllowed() | ||
{ | ||
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp'); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
view/adminhtml/templates/system/config/reseterrorsnoretry.phtml
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,8 @@ | ||
<div id="monkey_errorconfirmation" style="display:none;" data-mage-init='{"mailchimpconfirmation":{}}'> | ||
</div> | ||
<div class="actions actions-reset-errors"> | ||
<div id="validation_result" class="message-validation hidden"></div> | ||
<button onclick="mailchimpdeleteconfirmation('<?php echo $this->getAjaxCheckUrl() ?>')" class="action-reset-errors" type="button" id="<?php echo $block->getHtmlId() ?>"> | ||
<span><?php echo $block->escapeHtml($block->getButtonLabel()) ?></span> | ||
</button> | ||
</div> |