-
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.
- Loading branch information
1 parent
6909c5d
commit 8a53bea
Showing
7 changed files
with
300 additions
and
2 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,50 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: gonzalo | ||
* Date: 3/12/18 | ||
* Time: 2:12 PM | ||
*/ | ||
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; | ||
|
||
class CleanEcommerce 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/cleanecommerce.phtml'); | ||
} | ||
|
||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$originalData = $element->getOriginalData(); | ||
$this->addData( | ||
[ | ||
'button_label' => __($originalData['button_label']), | ||
'html_id' => $element->getHtmlId(), | ||
] | ||
); | ||
return $this->_toHtml(); | ||
} | ||
} |
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,92 @@ | ||
<?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 Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Exception\ValidatorException; | ||
use Symfony\Component\Config\Definition\Exception\Exception; | ||
|
||
class CheckEcommerce extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $resultJsonFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Helper\Data | ||
*/ | ||
protected $helper; | ||
/** | ||
* @var CollectionFactory | ||
*/ | ||
protected $collectionFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce | ||
*/ | ||
protected $chimpSyncEcommerce; | ||
|
||
/** | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param CollectionFactory $collectionFactory | ||
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSyncEcommerce | ||
* @param \Ebizmarts\MailChimp\Helper\Data $helper | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
JsonFactory $resultJsonFactory, | ||
\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $collectionFactory, | ||
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSyncEcommerce, | ||
\Ebizmarts\MailChimp\Helper\Data $helper | ||
) { | ||
|
||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->helper = $helper; | ||
$this->collectionFactory = $collectionFactory; | ||
$this->chimpSyncEcommerce = $chimpSyncEcommerce; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$valid = 1; | ||
$message = ''; | ||
|
||
$resultJson = $this->resultJsonFactory->create(); | ||
try { | ||
$collection = $this->collectionFactory->create(); | ||
$collection->getSelect()->joinLeft( | ||
['core_config' => 'core_config_data'], | ||
'value = mailchimp_store_id' | ||
); | ||
$collection->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['mailchimp_store_id']); | ||
$collection->getSelect()->where('value is null'); | ||
$collection->getSelect()->group('mailchimp_store_id'); | ||
$valid = $collection->count(); | ||
|
||
} catch (ValidatorException $e) { | ||
$valid = -1; | ||
$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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?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 Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Exception\ValidatorException; | ||
use Symfony\Component\Config\Definition\Exception\Exception; | ||
|
||
class CleanEcommerce extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $resultJsonFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Helper\Data | ||
*/ | ||
protected $helper; | ||
/** | ||
* @var CollectionFactory | ||
*/ | ||
protected $collectionFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce | ||
*/ | ||
protected $chimpSyncEcommerce; | ||
|
||
/** | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param CollectionFactory $collectionFactory | ||
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSyncEcommerce | ||
* @param \Ebizmarts\MailChimp\Helper\Data $helper | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
JsonFactory $resultJsonFactory, | ||
\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $collectionFactory, | ||
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSyncEcommerce, | ||
\Ebizmarts\MailChimp\Helper\Data $helper | ||
) { | ||
|
||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->helper = $helper; | ||
$this->collectionFactory = $collectionFactory; | ||
$this->chimpSyncEcommerce = $chimpSyncEcommerce; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$valid = 1; | ||
$message = ''; | ||
|
||
$resultJson = $this->resultJsonFactory->create(); | ||
try { | ||
$collection = $this->collectionFactory->create(); | ||
$collection->getSelect()->joinLeft( | ||
['core_config' => 'core_config_data'], | ||
'value = mailchimp_store_id' | ||
); | ||
$collection->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['mailchimp_store_id']); | ||
$collection->getSelect()->where('value is null'); | ||
$collection->getSelect()->group('mailchimp_store_id'); | ||
foreach($collection as $item) { | ||
$mailchimpStoreId = $item->getMailchimpStoreId(); | ||
$connection = $this->chimpSyncEcommerce->getResource()->getConnection(); | ||
$tableName = $this->chimpSyncEcommerce->getResource()->getMainTable(); | ||
$connection->delete( | ||
$tableName, | ||
"mailchimp_store_id = '$mailchimpStoreId'" | ||
); | ||
} | ||
} 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="actions actions-clean-ecommerce"> | ||
<div id="validation_result" class="message-validation hidden"></div> | ||
<button class="action-clean-ecommerce" type="button" id="<?php echo $block->getHtmlId() ?>"> | ||
<span><?php echo $block->escapeHtml($block->getButtonLabel()) ?></span> | ||
</button> | ||
</div> |
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