-
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.
Merge pull request #1187 from mailchimp/Issue-1184-2.2
closes #1184 for magento 2.2
- Loading branch information
Showing
7 changed files
with
193 additions
and
4 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 ResyncProducts 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/resyncproducts.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,95 @@ | ||
<?php | ||
/** | ||
* mc-magento2 Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento2 | ||
* @author Ebizmarts Team <[email protected]> | ||
* @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 ResyncProducts 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->resyncProducts($mailchimpStore); | ||
} 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
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 |
---|---|---|
|
@@ -16,7 +16,8 @@ | |
"storeGridUrl": "<?php echo $this->getUrl('mailchimp/stores/index');?>", | ||
"createWebhookUrl": "<?php echo $this->getUrl('mailchimp/ecommerce/createWebhook');?>", | ||
"getInterestUrl": "<?php echo $this->getUrl('mailchimp/ecommerce/getInterest');?>", | ||
"resyncSubscribersUrl": "<?php echo $this->getUrl('mailchimp/ecommerce/resyncSubscribers');?>"}}'> | ||
"resyncSubscribersUrl": "<?php echo $this->getUrl('mailchimp/ecommerce/resyncSubscribers');?>", | ||
"resyncProductsUrl": "<?php echo $this->getUrl('mailchimp/ecommerce/resyncProducts');?>"}}'> | ||
</div> | ||
<div style="background:#EAF0EE;border:1px solid #CCCCCC;margin-bottom:10px;padding:11px 0 0 10px;"> | ||
<h4> | ||
|
@@ -26,7 +27,7 @@ | |
<p><?php echo __('Need help? See our ') ?><a href="http://wiki.ebizmarts.com/installation" target="_blank"><?php echo __('Wiki') ?></a><?php echo __(' or browse our ') ?><a href="http://ebizmarts.com/forums" target="_blank"><?php echo __('support forums') ?></a><?php echo __(' Got feedback? ') ?><a href="mailto:[email protected]?Subject=MailChimp For Magento Version <?php echo $this->getModuleVersion()?>"><?php echo __('Email us') ?></a></p> | ||
<p><?php echo __('You can find more extension in our ') ?><a href="http://store.ebizmarts.com" target="_blank"><?php echo __('Store') ?></a></p> | ||
<?php if (!$this->getHasApiKey() ) : ?> | ||
<p><a style="padding-top: 5px;padding-bottom:5px;padding-left: 30px;padding-right: 30px;background-color:#D75F07 ;color:white;font-weight: bold" href="https://bit.ly/2KpDH5C" target="_blank">Support Mailchimp4Magento, Subscribe for a free Mailchimp Account!</a> </p> | ||
<p><a style="padding-top: 5px;padding-bottom:5px;padding-left: 30px;padding-right: 30px;background-color:#D75F07 ;color:white;font-weight: bold" href="https://bit.ly/2KpDH5C" target="_blank">Support Mailchimp4Magento, Subscribe for a free Mailchimp Account!</a> </p> | ||
<?php endif; ?> | ||
</div> | ||
</h4> | ||
|
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-resync-products"> | ||
<div id="validation_result" class="message-validation hidden"></div> | ||
<button class="action-resync-products" 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