diff --git a/Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php b/Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php
index 85563406..007adc92 100644
--- a/Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php
+++ b/Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php
@@ -1,22 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/29/17 1:55 PM
- * @file: Mailchimp.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\Customer\Edit\Tabs;
use Magento\Customer\Controller\RegistryConstants;
use Magento\Ui\Component\Layout\Tabs\TabInterface;
-use Magento\Backend\Block\Widget\Form;
-use Magento\Backend\Block\Widget\Form\Generic;
class Mailchimp extends \Magento\Backend\Block\Template implements TabInterface
{
@@ -30,7 +17,6 @@ class Mailchimp extends \Magento\Backend\Block\Template implements TabInterface
protected $_coreRegistry;
/**
- * Mailchimp constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Data\FormFactory $formFactory
@@ -80,6 +66,7 @@ public function canShowTab()
if ($this->getCustomerId()) {
return true;
}
+
return false;
}
@@ -91,12 +78,12 @@ public function isHidden()
if ($this->getCustomerId()) {
return false;
}
+
return true;
}
/**
* Tab class getter
- *
* @return string
*/
public function getTabClass()
@@ -106,7 +93,6 @@ public function getTabClass()
/**
* Return URL link to Tab content
- *
* @return string
*/
public function getTabUrl()
@@ -116,7 +102,6 @@ public function getTabUrl()
/**
* Tab should be loaded trough Ajax call
- *
* @return bool
*/
public function isAjaxLoaded()
diff --git a/Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php b/Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php
index 9f9bffd4..1767a8ed 100644
--- a/Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php
+++ b/Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/29/17 2:49 PM
- * @file: Customer.php
- */
+
namespace Ebizmarts\MailChimp\Block\Adminhtml\Customer\Edit\Tabs\View;
@@ -30,7 +20,6 @@ class Customer extends \Magento\Backend\Block\Template
protected $registry;
/**
- * Customer constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
diff --git a/Block/Adminhtml/Stores/Edit.php b/Block/Adminhtml/Stores/Edit.php
index adc266fc..b4896313 100644
--- a/Block/Adminhtml/Stores/Edit.php
+++ b/Block/Adminhtml/Stores/Edit.php
@@ -1,20 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/10/17 1:08 PM
- * @file: Edit.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores;
-use Magento\Backend\Block\Widget\Form\Container;
use Magento\Backend\Block\Widget\Context;
+use Magento\Backend\Block\Widget\Form\Container;
use Magento\Framework\Registry;
class Edit extends Container
@@ -23,8 +12,8 @@ class Edit extends Container
* @var Registry
*/
protected $_coreRegistry;
+
/**
- * Edit constructor.
* @param Context $context
* @param Registry $registry
* @param array $data
@@ -34,10 +23,10 @@ public function __construct(
Registry $registry,
array $data = []
) {
-
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
+
protected function _construct()
{
$this->_objectId = 'id';
@@ -68,7 +57,6 @@ protected function _construct()
/**
* Retrieve text for header element depending on loaded news
- *
* @return string
*/
public function getHeaderText()
@@ -76,6 +64,7 @@ public function getHeaderText()
$storeRegistry = $this->_coreRegistry->registry('mailchimp_stores');
if ($storeRegistry->getId()) {
$storeTitle = $this->escapeHtml($storeRegistry->getTitle());
+
return __("Edit Store '%1'", $storeTitle);
} else {
return __('Add Store');
diff --git a/Block/Adminhtml/Stores/Edit/Form.php b/Block/Adminhtml/Stores/Edit/Form.php
index 89e15340..8f31a518 100644
--- a/Block/Adminhtml/Stores/Edit/Form.php
+++ b/Block/Adminhtml/Stores/Edit/Form.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/10/17 4:04 PM
- * @file: Form.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit;
@@ -23,7 +12,7 @@ protected function _prepareForm()
$form = $this->_formFactory->create(
[
'data' => [
- 'id' => 'edit_form',
+ 'id' => 'edit_form',
'action' => $this->getData('action'),
'method' => 'post'
]
diff --git a/Block/Adminhtml/Stores/Edit/Tab/Address.php b/Block/Adminhtml/Stores/Edit/Tab/Address.php
index 9d067e1f..127793f4 100644
--- a/Block/Adminhtml/Stores/Edit/Tab/Address.php
+++ b/Block/Adminhtml/Stores/Edit/Tab/Address.php
@@ -1,22 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/12/17 5:07 PM
- * @file: Address.php
- */
+
namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab;
+use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;
-use Magento\Backend\Block\Template\Context;
-use Magento\Framework\Registry;
use Magento\Framework\Data\FormFactory;
+use Magento\Framework\Registry;
class Address extends Generic implements TabInterface
{
@@ -26,7 +16,6 @@ class Address extends Generic implements TabInterface
protected $_country;
/**
- * Address constructor.
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
@@ -40,15 +29,14 @@ public function __construct(
\Magento\Directory\Model\Config\Source\Country $country,
array $data = []
) {
-
$this->_country = $country;
parent::__construct($context, $registry, $formFactory, $data);
}
protected function _prepareForm()
{
- $model = $this->_coreRegistry->registry('mailchimp_stores');
- $form = $this->_formFactory->create();
+ $model = $this->_coreRegistry->registry('mailchimp_stores');
+ $form = $this->_formFactory->create();
$form->setHtmlIdPrefix('stores_');
$form->setFieldNameSuffix('stores');
$fieldset = $form->addFieldset(
@@ -66,40 +54,40 @@ protected function _prepareForm()
'address_address_one',
'text',
[
- 'name' => 'address_address_one',
- 'label' => __('Street'),
- 'required' => true
+ 'name' => 'address_address_one',
+ 'label' => __('Street'),
+ 'required' => true
]
);
$fieldset->addField(
'address_address_two',
'text',
[
- 'name' => 'address_address_two',
- 'label' => __('Street'),
- 'required' => false
+ 'name' => 'address_address_two',
+ 'label' => __('Street'),
+ 'required' => false
]
);
$fieldset->addField(
'address_city',
'text',
[
- 'name' => 'address_city',
- 'label' => __('City'),
- 'required' => true
+ 'name' => 'address_city',
+ 'label' => __('City'),
+ 'required' => true
]
);
$fieldset->addField(
'address_postal_code',
'text',
[
- 'name' => 'address_postal_code',
- 'label' => __('Postal Code'),
- 'required' => false
+ 'name' => 'address_postal_code',
+ 'label' => __('Postal Code'),
+ 'required' => false
]
);
$country = $this->_country->toOptionArray();
- $countryArray = [''=> __('Select one')];
+ $countryArray = ['' => __('Select one')];
foreach ($country as $c) {
$countryArray[$c['value']] = $c['label'];
}
@@ -107,10 +95,10 @@ protected function _prepareForm()
'address_country_code',
'select',
[
- 'name' => 'address_country_code',
- 'label' => __('Country'),
- 'required' => true,
- 'options' => $countryArray
+ 'name' => 'address_country_code',
+ 'label' => __('Country'),
+ 'required' => true,
+ 'options' => $countryArray
]
);
@@ -120,18 +108,22 @@ protected function _prepareForm()
return parent::_prepareForm();
}
+
public function getTabLabel()
{
return __('Store Address Info');
}
+
public function getTabTitle()
{
return __('Store Address Info');
}
+
public function canShowTab()
{
return true;
}
+
public function isHidden()
{
return false;
diff --git a/Block/Adminhtml/Stores/Edit/Tab/Info.php b/Block/Adminhtml/Stores/Edit/Tab/Info.php
index 0ea80bf5..9d983d08 100644
--- a/Block/Adminhtml/Stores/Edit/Tab/Info.php
+++ b/Block/Adminhtml/Stores/Edit/Tab/Info.php
@@ -1,23 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/12/17 11:03 AM
- * @file: Info.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab;
+use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;
-use Magento\Backend\Block\Template\Context;
-use Magento\Framework\Registry;
use Magento\Framework\Data\FormFactory;
+use Magento\Framework\Registry;
class Info extends Generic implements TabInterface
{
@@ -43,7 +32,6 @@ class Info extends Generic implements TabInterface
protected $_apikey;
/**
- * Info constructor.
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
@@ -65,19 +53,18 @@ public function __construct(
\Ebizmarts\MailChimp\Model\Config\Source\ApiKey $apiKey,
array $data = []
) {
-
- $this->_timezone = $timezone;
- $this->_yesno = $yesno;
- $this->_currency = $currency;
- $this->_locale = $locale;
- $this->_apikey = $apiKey;
+ $this->_timezone = $timezone;
+ $this->_yesno = $yesno;
+ $this->_currency = $currency;
+ $this->_locale = $locale;
+ $this->_apikey = $apiKey;
parent::__construct($context, $registry, $formFactory, $data);
}
protected function _prepareForm()
{
- $model = $this->_coreRegistry->registry('mailchimp_stores');
- $form = $this->_formFactory->create();
+ $model = $this->_coreRegistry->registry('mailchimp_stores');
+ $form = $this->_formFactory->create();
$form->setHtmlIdPrefix('stores_');
$form->setFieldNameSuffix('stores');
@@ -113,21 +100,21 @@ protected function _prepareForm()
'apikey',
'select',
[
- 'name' => 'apikey',
- 'label' => __('Apikey'),
- 'required' => true,
- 'options' => $apikeyArray,
+ 'name' => 'apikey',
+ 'label' => __('Apikey'),
+ 'required' => true,
+ 'options' => $apikeyArray,
]
);
- $listArray = [''=>__('Select first an ApiKey')];
+ $listArray = ['' => __('Select first an ApiKey')];
$fieldset->addField(
'list_id',
'select',
[
- 'name' => 'list_id',
- 'label' => __('List'),
- 'required' => true,
- 'options' => $listArray,
+ 'name' => 'list_id',
+ 'label' => __('List'),
+ 'required' => true,
+ 'options' => $listArray,
]
);
}
@@ -136,9 +123,9 @@ protected function _prepareForm()
'name',
'text',
[
- 'name' => 'name',
- 'label' => __('Name'),
- 'required' => true
+ 'name' => 'name',
+ 'label' => __('Name'),
+ 'required' => true
]
);
@@ -146,9 +133,9 @@ protected function _prepareForm()
'domain',
'text',
[
- 'name' => 'domain',
- 'label' => __('Domain'),
- 'required' => true
+ 'name' => 'domain',
+ 'label' => __('Domain'),
+ 'required' => true
]
);
@@ -156,13 +143,13 @@ protected function _prepareForm()
'email_address',
'text',
[
- 'name' => 'email_address',
- 'label' => __('Email'),
- 'required' => true
+ 'name' => 'email_address',
+ 'label' => __('Email'),
+ 'required' => true
]
);
$currency = $this->_currency->toOptionArray();
- $currencyArray = [''=> __('Select one')];
+ $currencyArray = ['' => __('Select one')];
foreach ($currency as $c) {
$currencyArray[$c['value']] = $c['label'];
}
@@ -170,14 +157,14 @@ protected function _prepareForm()
'currency_code',
'select',
[
- 'name' => 'currency_code',
- 'label' => __('Currency'),
- 'required' => true,
- 'options' => $currencyArray
+ 'name' => 'currency_code',
+ 'label' => __('Currency'),
+ 'required' => true,
+ 'options' => $currencyArray
]
);
$locale = $this->_locale->toOptionArray();
- $localeArray = [''=> __('Select one')];
+ $localeArray = ['' => __('Select one')];
foreach ($locale as $l) {
$localeArray[$l['value']] = $l['label'];
}
@@ -186,14 +173,14 @@ protected function _prepareForm()
'primary_locale',
'select',
[
- 'name' => 'primary_locale',
- 'label' => __('Locale'),
- 'required' => true,
- 'options' => $localeArray
+ 'name' => 'primary_locale',
+ 'label' => __('Locale'),
+ 'required' => true,
+ 'options' => $localeArray
]
);
$timezone = $this->_timezone->toOptionArray();
- $timezoneArray = [''=> __('Select one')];
+ $timezoneArray = ['' => __('Select one')];
foreach ($timezone as $t) {
$timezoneArray[$t['value']] = $t['label'];
}
@@ -201,19 +188,19 @@ protected function _prepareForm()
'timezone',
'select',
[
- 'name' => 'timezone',
- 'label' => __('TimeZone'),
- 'required' => true,
- 'options' => $timezoneArray
+ 'name' => 'timezone',
+ 'label' => __('TimeZone'),
+ 'required' => true,
+ 'options' => $timezoneArray
]
);
$fieldset->addField(
'phone',
'text',
[
- 'name' => 'phone',
- 'label' => __('Phone'),
- 'required' => true
+ 'name' => 'phone',
+ 'label' => __('Phone'),
+ 'required' => true
]
);
@@ -223,18 +210,22 @@ protected function _prepareForm()
return parent::_prepareForm();
}
+
public function getTabLabel()
{
return __('Store Info');
}
+
public function getTabTitle()
{
return __('Store Info');
}
+
public function canShowTab()
{
return true;
}
+
public function isHidden()
{
return false;
diff --git a/Block/Adminhtml/Stores/Edit/Tabs.php b/Block/Adminhtml/Stores/Edit/Tabs.php
index 3a04ce67..cee5a747 100644
--- a/Block/Adminhtml/Stores/Edit/Tabs.php
+++ b/Block/Adminhtml/Stores/Edit/Tabs.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/12/17 11:01 AM
- * @file: Tabs.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit;
@@ -18,8 +7,6 @@
class Tabs extends WidgetTabs
{
/**
- * Class constructor
- *
* @return void
*/
protected function _construct()
diff --git a/Block/Adminhtml/System/Config/Account.php b/Block/Adminhtml/System/Config/Account.php
index 4de36778..2da4b08f 100644
--- a/Block/Adminhtml/System/Config/Account.php
+++ b/Block/Adminhtml/System/Config/Account.php
@@ -1,13 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config;
@@ -20,7 +11,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$html .= '
';
if ($values) {
foreach ($values as $dat) {
- if ($dat['value']!=='') {
+ if ($dat['value'] !== '') {
$html .= "- {$dat['label']}: {$dat['value']}
";
} else {
$html .= "- {$dat['label']}
";
diff --git a/Block/Adminhtml/System/Config/CleanEcommerce.php b/Block/Adminhtml/System/Config/CleanEcommerce.php
index 48bff77d..1dfb460b 100644
--- a/Block/Adminhtml/System/Config/CleanEcommerce.php
+++ b/Block/Adminhtml/System/Config/CleanEcommerce.php
@@ -1,10 +1,5 @@
_helper = $helper;
parent::__construct($context, $data);
}
@@ -45,6 +38,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
}
diff --git a/Block/Adminhtml/System/Config/CreateAbandonedCart.php b/Block/Adminhtml/System/Config/CreateAbandonedCart.php
index d92b6611..c201727f 100644
--- a/Block/Adminhtml/System/Config/CreateAbandonedCart.php
+++ b/Block/Adminhtml/System/Config/CreateAbandonedCart.php
@@ -1,21 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config;
class CreateAbandonedCart extends \Magento\Config\Block\System\Config\Form\Field
{
- protected $_template = 'system/config/create_abandonedcart_automation.phtml';
+ protected $_template = 'system/config/create_abandonedcart_automation.phtml';
- private $_url = "https://admin.mailchimp.com/#/create-campaign/explore/abandonedCart";
+ private $_url = "https://admin.mailchimp.com/#/create-campaign/explore/abandonedCart";
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
@@ -25,14 +16,15 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->authorizeRequestUrl(),
+ 'button_url' => $this->authorizeRequestUrl(),
'html_id' => $element->getHtmlId(),
]);
- return parent::_toHtml();
- ;
+
+ return parent::_toHtml();;
}
+
public function authorizeRequestUrl()
{
return $this->_url;
}
-}
\ No newline at end of file
+}
diff --git a/Block/Adminhtml/System/Config/CreateWebhook.php b/Block/Adminhtml/System/Config/CreateWebhook.php
index 45411be2..1ec42392 100644
--- a/Block/Adminhtml/System/Config/CreateWebhook.php
+++ b/Block/Adminhtml/System/Config/CreateWebhook.php
@@ -1,10 +1,5 @@
_helper = $helper;
parent::__construct($context, $data);
}
@@ -46,6 +39,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
@@ -55,20 +49,23 @@ public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractEleme
$label = $originalData['button_label'];
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->getAjaxCreateWebhookUrl(),
+ 'button_url' => $this->getAjaxCreateWebhookUrl(),
'html_id' => $element->getHtmlId(),
]);
+
return $this->_toHtml();
}
+
public function getAjaxCreateWebhookUrl()
{
$params = $this->getRequest()->getParams();
$scope = [];
if (isset($params['website'])) {
- $scope = ['website'=>$params['website']];
+ $scope = ['website' => $params['website']];
} elseif (isset($params['store'])) {
- $scope = ['store'=>$params['store']];
+ $scope = ['store' => $params['store']];
}
+
return $this->_urlBuilder->getUrl('mailchimp/ecommerce/CreateWebhook', $scope);
}
}
diff --git a/Block/Adminhtml/System/Config/Date.php b/Block/Adminhtml/System/Config/Date.php
index 6a91e101..73dca4d1 100644
--- a/Block/Adminhtml/System/Config/Date.php
+++ b/Block/Adminhtml/System/Config/Date.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 9/30/16 2:38 PM
- * @file: Date.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config;
@@ -19,6 +8,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
{
$element->setDateFormat(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
$element->setTimeFormat(null);
+
return parent::render($element);
}
}
diff --git a/Block/Adminhtml/System/Config/DeleteStore.php b/Block/Adminhtml/System/Config/DeleteStore.php
index f7154f7c..ac0754df 100644
--- a/Block/Adminhtml/System/Config/DeleteStore.php
+++ b/Block/Adminhtml/System/Config/DeleteStore.php
@@ -1,15 +1,4 @@
- * @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;
@@ -21,7 +10,6 @@ class DeleteStore extends \Magento\Config\Block\System\Config\Form\Field
private $_helper;
/**
- * ResetErrors constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param array $data
@@ -31,7 +19,6 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data = []
) {
-
$this->_helper = $helper;
parent::__construct($context, $data);
}
@@ -52,6 +39,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
@@ -61,20 +49,23 @@ public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractEleme
$label = $originalData['button_label'];
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->getAjaxCheckUrl(),
+ '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']];
+ $scope = ['website' => $params['website']];
} elseif (isset($params['store'])) {
- $scope = ['store'=>$params['store']];
+ $scope = ['store' => $params['store']];
}
+
return $this->_urlBuilder->getUrl('mailchimp/ecommerce/DeleteStore', $scope);
}
}
diff --git a/Block/Adminhtml/System/Config/Fieldset/Hint.php b/Block/Adminhtml/System/Config/Fieldset/Hint.php
index f9a3f325..f3947cfa 100644
--- a/Block/Adminhtml/System/Config/Fieldset/Hint.php
+++ b/Block/Adminhtml/System/Config/Fieldset/Hint.php
@@ -1,13 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Fieldset;
@@ -36,7 +27,6 @@ class Hint extends \Magento\Backend\Block\Template implements
private $_moduleVersion;
/**
- * Hint constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\App\ProductMetadataInterface $productMetaData
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -53,9 +43,10 @@ public function __construct(
parent::__construct($context, $data);
$this->_metaData = $productMetaData;
$this->_helper = $helper;
- $this->_moduleVersion = $moduleVersion;
+ $this->_moduleVersion = $moduleVersion;
$this->_context = $context;
}
+
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return mixed
@@ -69,6 +60,7 @@ public function getModuleVersion()
{
return $this->_moduleVersion->getModuleVersion('Ebizmarts_MailChimp');
}
+
public function getHasApiKey()
{
$apikey = $this->_helper->getApiKey($this->_context->getStoreManager()->getStore()->getId());
@@ -78,6 +70,7 @@ public function getHasApiKey()
return false;
}
}
+
public function getScope()
{
$params = $this->getRequest()->getParams();
@@ -87,8 +80,10 @@ public function getScope()
} elseif (isset($params['store'])) {
$scope = 'store';
}
+
return $scope;
}
+
public function getScopeId()
{
$params = $this->getRequest()->getParams();
@@ -98,6 +93,7 @@ public function getScopeId()
} elseif (isset($params['store'])) {
$scopeId = $params['store'];
}
+
return $scopeId;
}
}
diff --git a/Block/Adminhtml/System/Config/FixMailchimpJS.php b/Block/Adminhtml/System/Config/FixMailchimpJS.php
index 5956e8c3..b9e02c2e 100644
--- a/Block/Adminhtml/System/Config/FixMailchimpJS.php
+++ b/Block/Adminhtml/System/Config/FixMailchimpJS.php
@@ -1,10 +1,5 @@
_helper = $helper;
parent::__construct($context, $data);
}
@@ -45,6 +38,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
}
diff --git a/Block/Adminhtml/System/Config/Form/Field/CustomerMap.php b/Block/Adminhtml/System/Config/Form/Field/CustomerMap.php
index 1598d08b..6ebed3ab 100644
--- a/Block/Adminhtml/System/Config/Form/Field/CustomerMap.php
+++ b/Block/Adminhtml/System/Config/Form/Field/CustomerMap.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/27/17 12:01 PM
- * @file: CustomerMap.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;
@@ -18,8 +7,8 @@ class CustomerMap extends \Magento\Config\Block\System\Config\Form\Field\FieldAr
/**
* @var VarsMap
*/
- protected $_varsRenderer=null;
- protected $_mailchimpRenderer=null;
+ protected $_varsRenderer = null;
+ protected $_mailchimpRenderer = null;
protected function _getVarsRenderer()
{
@@ -31,8 +20,10 @@ protected function _getVarsRenderer()
);
$this->_varsRenderer->setClass('customer_field_select');
}
+
return $this->_varsRenderer;
}
+
protected function _getMailchimpRenderer()
{
if (!$this->_mailchimpRenderer) {
@@ -43,12 +34,12 @@ protected function _getMailchimpRenderer()
);
$this->_mailchimpRenderer->setClass('mailchimp_field_select');
}
+
return $this->_mailchimpRenderer;
}
protected function _prepareToRender()
{
-// $this->addColumn('mailchimp', ['label' => __('Mailchimp')]);
$this->addColumn(
'mailchimp_field_id',
['label' => __('Mailchimp'), 'renderer' => $this->_getMailchimpRenderer()]
@@ -60,6 +51,7 @@ protected function _prepareToRender()
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
+
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
{
$optionExtraAttr = [];
@@ -67,8 +59,7 @@ protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
'selected="selected"';
$optionExtraAttr['option_' . $this->_getMailchimpRenderer()->calcOptionHash(
$row->getData('mailchimp_field_id')
- )
- ] =
+ )] =
'selected="selected"';
$row->setData(
'option_extra_attrs',
diff --git a/Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php b/Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php
index c123d9e8..7c16ebf0 100755
--- a/Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php
+++ b/Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/9/18 1:17 PM
- * @file: MailchimpMap.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;
@@ -29,7 +18,6 @@ class MailchimpMap extends \Magento\Framework\View\Element\Html\Select
protected $_request;
/**
- * MailchimpMap constructor.
* @param \Magento\Framework\View\Element\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -41,17 +29,16 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data = []
) {
-
parent::__construct($context, $data);
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
- $this->_request = $context->getRequest();
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
+ $this->_request = $context->getRequest();
}
protected function _getMailchimpTags()
{
$ret = [];
- $storeId = (int) $this->_request->getParam("store", 0);
+ $storeId = (int)$this->_request->getParam("store", 0);
if ($this->_request->getParam('website', 0)) {
$scope = 'website';
$storeId = $this->_request->getParam('website', 0);
@@ -82,8 +69,10 @@ protected function _getMailchimpTags()
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
+
return $ret;
}
+
public function setInputName($value)
{
return $this->setName($value);
@@ -91,7 +80,6 @@ public function setInputName($value)
/**
* Render block HTML
- *
* @return string
*/
public function _toHtml()
@@ -101,6 +89,7 @@ public function _toHtml()
$this->addOption($attId, $this->escapeHtmlAttr($attLabel));
}
}
+
return parent::_toHtml();
}
}
diff --git a/Block/Adminhtml/System/Config/Form/Field/VarsMap.php b/Block/Adminhtml/System/Config/Form/Field/VarsMap.php
index 9ef70f80..14e3af84 100644
--- a/Block/Adminhtml/System/Config/Form/Field/VarsMap.php
+++ b/Block/Adminhtml/System/Config/Form/Field/VarsMap.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/27/17 3:41 PM
- * @file: VarsMap.php
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;
@@ -19,8 +8,8 @@ class VarsMap extends \Magento\Framework\View\Element\Html\Select
* @var \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory
*/
private $_attCollection;
+
/**
- * VarsMap constructor.
* @param \Magento\Framework\View\Element\Context $context
* @param \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attCollection
* @param array $data
@@ -30,26 +19,26 @@ public function __construct(
\Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attCollection,
array $data = []
) {
-
parent::__construct($context, $data);
$this->_attCollection = $attCollection;
}
+
protected function _getAddressAtt()
{
$ret = [];
- $ret['default_shipping##zip'] = __('Shipping Zip Code');
+ $ret['default_shipping##zip'] = __('Shipping Zip Code');
$ret['default_shipping##country'] = __('Shipping Country');
- $ret['default_shipping##city'] = __('Shipping City');
- $ret['default_shipping##state'] = __('Shipping State');
- $ret['default_shipping##telephone'] = __('Shipping Telephone');
- $ret['default_shipping##company'] = __('Shipping Company');
-
- $ret['default_billing##zip'] = __('Billing Zip Code');
- $ret['default_billing##country'] = __('Billing Country');
- $ret['default_billing##city'] = __('Billing City');
- $ret['default_billing##state'] = __('Billing State');
- $ret['default_billing##telephone'] = __('Billing Telephone');
- $ret['default_billing##company'] = __('Billing Company');
+ $ret['default_shipping##city'] = __('Shipping City');
+ $ret['default_shipping##state'] = __('Shipping State');
+ $ret['default_shipping##telephone'] = __('Shipping Telephone');
+ $ret['default_shipping##company'] = __('Shipping Company');
+
+ $ret['default_billing##zip'] = __('Billing Zip Code');
+ $ret['default_billing##country'] = __('Billing Country');
+ $ret['default_billing##city'] = __('Billing City');
+ $ret['default_billing##state'] = __('Billing State');
+ $ret['default_billing##telephone'] = __('Billing Telephone');
+ $ret['default_billing##company'] = __('Billing Company');
return $ret;
}
@@ -64,6 +53,7 @@ protected function _getBindableAttributes()
$ret = $systemAtt + $extraAtt;
natsort($ret);
+
return $ret;
}
@@ -79,6 +69,7 @@ protected function _getCustomerAtt()
}
natsort($ret);
+
return $ret;
}
@@ -89,7 +80,6 @@ public function setInputName($value)
/**
* Render block HTML
- *
* @return string
*/
public function _toHtml()
@@ -99,6 +89,7 @@ public function _toHtml()
$this->addOption($attId, $this->escapeHtmlAttr($attLabel));
}
}
+
return parent::_toHtml();
}
}
diff --git a/Block/Adminhtml/System/Config/OauthWizard.php b/Block/Adminhtml/System/Config/OauthWizard.php
index 4b4b7462..b3ac482e 100644
--- a/Block/Adminhtml/System/Config/OauthWizard.php
+++ b/Block/Adminhtml/System/Config/OauthWizard.php
@@ -1,24 +1,15 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config;
class OauthWizard extends \Magento\Config\Block\System\Config\Form\Field
{
- protected $_template = 'system/config/oauth_wizard.phtml';
+ protected $_template = 'system/config/oauth_wizard.phtml';
- private $_authorizeUri = "https://login.mailchimp.com/oauth2/authorize";
- private $_accessTokenUri = "https://login.mailchimp.com/oauth2/token";
- private $_redirectUri = "https://ebizmarts.com/magento/mc-magento2/oauth2/complete.php";
- private $_clientId = 390007044048;
+ private $_authorizeUri = "https://login.mailchimp.com/oauth2/authorize";
+ private $_accessTokenUri = "https://login.mailchimp.com/oauth2/token";
+ private $_redirectUri = "https://ebizmarts.com/magento/mc-magento2/oauth2/complete.php";
+ private $_clientId = 390007044048;
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
@@ -28,15 +19,15 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->authorizeRequestUrl(),
+ 'button_url' => $this->authorizeRequestUrl(),
'html_id' => $element->getHtmlId(),
]);
- return parent::_toHtml();
- ;
+
+ return parent::_toHtml();;
}
+
public function authorizeRequestUrl()
{
-
$url = $this->_authorizeUri;
$redirectUri = urlencode($this->_redirectUri);
diff --git a/Block/Adminhtml/System/Config/ResetErrors.php b/Block/Adminhtml/System/Config/ResetErrors.php
index a6cf80df..ec595d7c 100644
--- a/Block/Adminhtml/System/Config/ResetErrors.php
+++ b/Block/Adminhtml/System/Config/ResetErrors.php
@@ -1,15 +1,4 @@
- * @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;
@@ -21,7 +10,6 @@ class ResetErrors extends \Magento\Config\Block\System\Config\Form\Field
private $_helper;
/**
- * ResetErrors constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param array $data
@@ -31,7 +19,6 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data = []
) {
-
$this->_helper = $helper;
parent::__construct($context, $data);
}
@@ -52,6 +39,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
@@ -61,20 +49,23 @@ public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractEleme
$label = $originalData['button_label'];
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->getAjaxCheckUrl(),
+ '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']];
+ $scope = ['website' => $params['website']];
} elseif (isset($params['store'])) {
- $scope = ['store'=>$params['store']];
+ $scope = ['store' => $params['store']];
}
+
return $this->_urlBuilder->getUrl('mailchimp/ecommerce/ResetLocalErrors', $scope);
}
}
diff --git a/Block/Adminhtml/System/Config/ResetErrorsNoRetry.php b/Block/Adminhtml/System/Config/ResetErrorsNoRetry.php
index ad01db29..e7df8314 100644
--- a/Block/Adminhtml/System/Config/ResetErrorsNoRetry.php
+++ b/Block/Adminhtml/System/Config/ResetErrorsNoRetry.php
@@ -1,15 +1,4 @@
- * @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;
@@ -21,7 +10,6 @@ class ResetErrorsNoRetry extends \Magento\Config\Block\System\Config\Form\Field
private $_helper;
/**
- * ResetErrors constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param array $data
@@ -31,7 +19,6 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data = []
) {
-
$this->_helper = $helper;
parent::__construct($context, $data);
}
@@ -52,6 +39,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
@@ -61,20 +49,23 @@ public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractEleme
$label = $originalData['button_label'];
$this->addData([
'button_label' => __($label),
- 'button_url' => $this->getAjaxCheckUrl(),
+ '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']];
+ $scope = ['website' => $params['website']];
} elseif (isset($params['store'])) {
- $scope = ['store'=>$params['store']];
+ $scope = ['store' => $params['store']];
}
+
return $this->_urlBuilder->getUrl('mailchimp/ecommerce/ResetLocalErrorsNoRetry', $scope);
}
}
diff --git a/Block/Adminhtml/System/Config/ResetStore.php b/Block/Adminhtml/System/Config/ResetStore.php
index d4e4f713..ffd9ecef 100644
--- a/Block/Adminhtml/System/Config/ResetStore.php
+++ b/Block/Adminhtml/System/Config/ResetStore.php
@@ -1,15 +1,4 @@
- * @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;
@@ -21,7 +10,6 @@ class ResetStore extends \Magento\Config\Block\System\Config\Form\Field
private $_helper;
/**
- * ResetErrors constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param array $data
@@ -31,7 +19,7 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data = []
) {
-
+
$this->_helper = $helper;
parent::__construct($context, $data);
}
diff --git a/Block/Adminhtml/System/Config/ResyncProducts.php b/Block/Adminhtml/System/Config/ResyncProducts.php
index 3a20b83d..98188d05 100644
--- a/Block/Adminhtml/System/Config/ResyncProducts.php
+++ b/Block/Adminhtml/System/Config/ResyncProducts.php
@@ -1,10 +1,5 @@
_helper = $helper;
parent::__construct($context, $data);
}
@@ -45,6 +38,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
}
diff --git a/Block/Adminhtml/System/Config/ResyncSubscriber.php b/Block/Adminhtml/System/Config/ResyncSubscriber.php
index 7371366f..182590e3 100644
--- a/Block/Adminhtml/System/Config/ResyncSubscriber.php
+++ b/Block/Adminhtml/System/Config/ResyncSubscriber.php
@@ -1,10 +1,5 @@
_helper = $helper;
parent::__construct($context, $data);
}
@@ -45,6 +38,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'html_id' => $element->getHtmlId(),
]
);
+
return $this->_toHtml();
}
}
diff --git a/Block/Catcher.php b/Block/Catcher.php
index 446c3e95..0e7d6112 100644
--- a/Block/Catcher.php
+++ b/Block/Catcher.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/25/17 3:35 PM
- * @file: Catcher.php
- */
+
namespace Ebizmarts\MailChimp\Block;
use Magento\Framework\View\Element\Template;
@@ -20,6 +10,4 @@ class Catcher extends Template
* @var string $_template
*/
protected $_template = "catcher.phtml";
-
- // write your methods here...
}
diff --git a/Block/Checkout/Success.php b/Block/Checkout/Success.php
index 1ce60e30..ea274645 100644
--- a/Block/Checkout/Success.php
+++ b/Block/Checkout/Success.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/13/17 4:41 PM
- * @file: Success.php
- */
+
namespace Ebizmarts\MailChimp\Block\Checkout;
class Success extends \Magento\Framework\View\Element\Template
@@ -36,7 +26,6 @@ class Success extends \Magento\Framework\View\Element\Template
protected $_context;
/**
- * Success constructor.
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -52,13 +41,12 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
array $data
) {
-
parent::__construct($context, $data);
- $this->_checkoutSession = $checkoutSession;
- $this->_helper = $helper;
- $this->_subscriberFactory = $subscriberFactory;
- $this->_interestGroupFactory= $interestGroupFactory;
- $this->_context = $context;
+ $this->_checkoutSession = $checkoutSession;
+ $this->_helper = $helper;
+ $this->_subscriberFactory = $subscriberFactory;
+ $this->_interestGroupFactory = $interestGroupFactory;
+ $this->_context = $context;
}
public function getInterest()
@@ -72,32 +60,40 @@ public function getInterest()
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
+
protected function getValues($category)
{
- $rc =[];
+ $rc = [];
foreach ($category as $c) {
- $rc[] = ['value'=>$c['id'],'label'=>$c['name']];
+ $rc[] = ['value' => $c['id'], 'label' => $c['name']];
}
+
return $rc;
}
+
public function getMessageBefore()
{
return $this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_INTEREST_SUCCESS_HTML_BEFORE);
}
+
public function getMessageAfter()
{
return $this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_INTEREST_SUCCESS_HTML_AFTER);
}
+
public function getFormUrl()
{
$order = $this->_checkoutSession->getLastRealOrder();
+
return $this->_helper->getSuccessInterestUrl($order->getStoreId());
}
+
public function _toHtml()
{
if (!$this->_helper->isMailChimpEnabled($this->_context->getStoreManager()->getStore()->getId())) {
return "";
}
+
return parent::_toHtml();
}
}
diff --git a/Block/Loadquote.php b/Block/Loadquote.php
index d1b6a5c3..26db1ff8 100644
--- a/Block/Loadquote.php
+++ b/Block/Loadquote.php
@@ -1,10 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/8/17 12:00 PM
- * @file: Mailchimpjs.php
- */
namespace Ebizmarts\MailChimp\Block;
@@ -29,7 +18,6 @@ class Mailchimpjs extends \Magento\Framework\View\Element\Template
protected $_secureHTtmlRender;
/**
- * Mailchimpjs constructor.
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param array $data
@@ -41,9 +29,9 @@ public function __construct(
array $data
) {
parent::__construct($context, $data);
- $this->_helper = $helper;
- $this->_storeManager = $context->getStoreManager();
- $this->_secureHTtmlRender = $secureHTtmlRender;
+ $this->_helper = $helper;
+ $this->_storeManager = $context->getStoreManager();
+ $this->_secureHTtmlRender = $secureHTtmlRender;
}
public function getJsUrl()
@@ -51,11 +39,13 @@ public function getJsUrl()
$storeId = $this->_storeManager->getStore()->getId();
$url = $this->_scopeConfig->getValue(
- \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_JS_URL, ScopeInterface::SCOPE_STORES,
+ \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_JS_URL,
+ ScopeInterface::SCOPE_STORES,
$storeId
);
$active = $this->_scopeConfig->getValue(
- \Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORES,
+ \Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE,
+ ScopeInterface::SCOPE_STORES,
$storeId
);
@@ -67,6 +57,7 @@ public function getJsUrl()
return $url;
}
+
public function getRender()
{
return $this->_secureHTtmlRender;
diff --git a/Block/Newsletter.php b/Block/Newsletter.php
index 6c8458f2..227b5085 100644
--- a/Block/Newsletter.php
+++ b/Block/Newsletter.php
@@ -1,21 +1,10 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/23/17 4:40 PM
- * @file: Newsletter.php
- */
namespace Ebizmarts\MailChimp\Block;
+use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Controller\RegistryConstants;
use Magento\Framework\Exception\NoSuchEntityException;
-use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Registry;
class Newsletter extends \Magento\Framework\View\Element\Template
@@ -59,9 +48,8 @@ public function __construct(
Registry $registry,
array $data
) {
-
parent::__construct($context, $data);
- $this->_helper = $helper;
+ $this->_helper = $helper;
$this->subscriberFactory = $subscriberFactory;
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
@@ -72,14 +60,17 @@ public function getInterest()
{
$customer = $this->getCurrentCustomer();
$subscriber = $this->subscriberFactory->create();
- $subscriber->loadByCustomer($customer->getId(),$customer->getStoreId());
+ $subscriber->loadByCustomer($customer->getId(), $customer->getStoreId());
+
// $subscriber = $this->getSubscriptionObject();
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
+
public function getFormUrl()
{
- return $this->getUrl('mailchimp/accountmanage/save');
+ return $this->getUrl('mailchimp/accountmanage/save');
}
+
private function getCurrentCustomer()
{
$customerId = $this->getCurrentCustomerId();
@@ -91,6 +82,7 @@ private function getCurrentCustomer()
return $customer;
}
+
private function getCurrentCustomerId(): int
{
return (int)$this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
diff --git a/Block/Subscribe.php b/Block/Subscribe.php
index 1012a305..de84879a 100644
--- a/Block/Subscribe.php
+++ b/Block/Subscribe.php
@@ -2,8 +2,8 @@
namespace Ebizmarts\MailChimp\Block;
+use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
use Magento\Framework\View\Element\Template;
-use \Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
class Subscribe extends \Magento\Newsletter\Block\Subscribe
{
@@ -25,8 +25,7 @@ public function __construct(
Template\Context $context,
MailchimpHelper $helper,
array $data = []
- )
- {
+ ) {
parent::__construct($context, $data);
$this->context = $context;
$this->helper = $helper;
@@ -34,8 +33,8 @@ public function __construct(
public function getPopupUrl()
{
-
$storeId = $this->context->getStoreManager()->getStore()->getId();
- return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId);
+
+ return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL, $storeId);
}
-}
\ No newline at end of file
+}
diff --git a/Controller/Adminhtml/Batch/GetResponse.php b/Controller/Adminhtml/Batch/GetResponse.php
index 0a0c0566..8b99a6ee 100644
--- a/Controller/Adminhtml/Batch/GetResponse.php
+++ b/Controller/Adminhtml/Batch/GetResponse.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/3/17 3:28 PM
- * @file: Getresponse.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Batch;
@@ -40,7 +29,6 @@ class GetResponse extends \Magento\Backend\App\Action
protected $_driver;
/**
- * Getresponse constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $errorsFactory
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -55,16 +43,16 @@ public function __construct(
\Magento\Framework\Filesystem\Driver\File $driver
) {
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_batchFactory = $_batchFactory;
- $this->_result = $result;
- $this->_helper = $helper;
- $this->_driver = $driver;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_batchFactory = $_batchFactory;
+ $this->_result = $result;
+ $this->_helper = $helper;
+ $this->_driver = $driver;
}
public function execute()
{
- $batchId = $this->getRequest()->getParam('id');
+ $batchId = $this->getRequest()->getParam('id');
$batches = $this->_batchFactory->create();
$batches->getResource()->load($batches, $batchId);
$batchId = $batches->getBatchId();
@@ -73,7 +61,7 @@ public function execute()
do {
$counter++;
$files = $this->_result->getBatchResponse($batchId, $batches->getStoreId());
- if ($files===false) {
+ if ($files === false) {
$fileContent = "Response was deleted from MailChimp servers";
break;
}
@@ -90,21 +78,25 @@ public function execute()
$this->_driver->deleteFile($file);
}
$baseDir = $this->_helper->getBaseDir();
- if ($this->_driver->isDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- \Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId)) {
+ if ($this->_driver->isDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ \Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
+ )) {
$this->_driver->deleteDirectory(
$baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
\Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
);
}
- } while (!count($fileContent) && $counter_resultFactory->create(ResultFactory::TYPE_JSON);
- $resultJson->setHeader('Content-disposition', 'attachment; filename='.$batchId.'.json');
+ } while (!count($fileContent) && $counter < self::MAX_RETRIES);
+ $resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
+ $resultJson->setHeader('Content-disposition', 'attachment; filename=' . $batchId . '.json');
$resultJson->setHeader('Content-type', 'application/json');
$data = json_encode($fileContent, JSON_PRETTY_PRINT);
$resultJson->setJsonData($data);
+
return $resultJson;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::batch_grid');
diff --git a/Controller/Adminhtml/Batch/Index.php b/Controller/Adminhtml/Batch/Index.php
index d9583f5c..37d83da1 100644
--- a/Controller/Adminhtml/Batch/Index.php
+++ b/Controller/Adminhtml/Batch/Index.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/28/16 4:58 PM
- * @file: Index.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Batch;
class Index extends \Magento\Backend\App\Action
@@ -20,7 +10,6 @@ class Index extends \Magento\Backend\App\Action
protected $resultPageFactory;
/**
- * Index constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
@@ -32,12 +21,15 @@ public function __construct(
parent::__construct($context);
}
+
public function execute()
{
$page = $this->resultPageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Mailchimp Batches'));
+
return $page;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::batch_grid');
diff --git a/Controller/Adminhtml/Cron/Index.php b/Controller/Adminhtml/Cron/Index.php
index 5a656d7c..635e6e00 100644
--- a/Controller/Adminhtml/Cron/Index.php
+++ b/Controller/Adminhtml/Cron/Index.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/28/16 4:58 PM
- * @file: Index.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Cron;
class Index extends \Magento\Backend\App\Action
@@ -20,7 +10,6 @@ class Index extends \Magento\Backend\App\Action
protected $resultPageFactory;
/**
- * Index constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
@@ -32,12 +21,15 @@ public function __construct(
parent::__construct($context);
}
+
public function execute()
{
$page = $this->resultPageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Mailchimp Cron'));
+
return $page;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::cron_grid');
diff --git a/Controller/Adminhtml/Ecommerce/CheckEcommerce.php b/Controller/Adminhtml/Ecommerce/CheckEcommerce.php
index 922898e3..ad31f85c 100644
--- a/Controller/Adminhtml/Ecommerce/CheckEcommerce.php
+++ b/Controller/Adminhtml/Ecommerce/CheckEcommerce.php
@@ -1,22 +1,10 @@
- * @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
{
@@ -51,12 +39,11 @@ public function __construct(
\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;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->collectionFactory = $collectionFactory;
+ $this->chimpSyncEcommerce = $chimpSyncEcommerce;
}
public function execute()
@@ -75,16 +62,17 @@ public function execute()
$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');
diff --git a/Controller/Adminhtml/Ecommerce/CleanEcommerce.php b/Controller/Adminhtml/Ecommerce/CleanEcommerce.php
index 5298c440..4da6b2b7 100644
--- a/Controller/Adminhtml/Ecommerce/CleanEcommerce.php
+++ b/Controller/Adminhtml/Ecommerce/CleanEcommerce.php
@@ -1,22 +1,10 @@
- * @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
{
@@ -51,12 +39,11 @@ public function __construct(
\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;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->collectionFactory = $collectionFactory;
+ $this->chimpSyncEcommerce = $chimpSyncEcommerce;
}
public function execute()
@@ -74,7 +61,7 @@ public function execute()
$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) {
+ foreach ($collection as $item) {
$mailchimpStoreId = $item->getMailchimpStoreId();
$connection = $this->chimpSyncEcommerce->getResource()->getConnection();
$tableName = $this->chimpSyncEcommerce->getResource()->getMainTable();
@@ -87,11 +74,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/CreateWebhook.php b/Controller/Adminhtml/Ecommerce/CreateWebhook.php
index db029081..00dbff59 100644
--- a/Controller/Adminhtml/Ecommerce/CreateWebhook.php
+++ b/Controller/Adminhtml/Ecommerce/CreateWebhook.php
@@ -1,21 +1,8 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/12/18 4:14 PM
- * @file: CreateWebhook.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 CreateWebhook extends \Magento\Backend\App\Action
{
@@ -33,7 +20,6 @@ class CreateWebhook extends \Magento\Backend\App\Action
protected $storeManager;
/**
- * DeleteStore constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param JsonFactory $resultJsonFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface
@@ -47,11 +33,10 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Config\Model\ResourceModel\Config $config
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->storeManager = $storeManagerInterface;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->storeManager = $storeManagerInterface;
}
public function execute()
@@ -64,7 +49,7 @@ public function execute()
$scope = $params['scope'];
$scopeId = $params['scopeId'];
- if ($apiKey=='******') {
+ if ($apiKey == '******') {
$apiKey = $this->helper->getApiKey($scopeId, $scope);
}
@@ -80,6 +65,7 @@ public function execute()
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/DeleteStore.php b/Controller/Adminhtml/Ecommerce/DeleteStore.php
index dcea11be..6fa86298 100644
--- a/Controller/Adminhtml/Ecommerce/DeleteStore.php
+++ b/Controller/Adminhtml/Ecommerce/DeleteStore.php
@@ -1,21 +1,9 @@
- * @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 DeleteStore extends \Magento\Backend\App\Action
{
@@ -37,7 +25,6 @@ class DeleteStore extends \Magento\Backend\App\Action
protected $_config;
/**
- * DeleteStore constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param JsonFactory $resultJsonFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface
@@ -51,12 +38,11 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Config\Model\ResourceModel\Config $config
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->storeManager = $storeManagerInterface;
- $this->_config = $config;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->storeManager = $storeManagerInterface;
+ $this->_config = $config;
}
public function execute()
@@ -89,11 +75,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/FixMailchimpJS.php b/Controller/Adminhtml/Ecommerce/FixMailchimpJS.php
index 70646e4c..f700eef5 100644
--- a/Controller/Adminhtml/Ecommerce/FixMailchimpJS.php
+++ b/Controller/Adminhtml/Ecommerce/FixMailchimpJS.php
@@ -1,22 +1,10 @@
- * @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 FixMailchimpJS extends \Magento\Backend\App\Action
{
@@ -48,12 +36,11 @@ public function __construct(
\Magento\Framework\App\Cache\TypeListInterface $typeList,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->config = $config;
- $this->typeList = $typeList;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->config = $config;
+ $this->typeList = $typeList;
}
public function execute()
@@ -72,7 +59,7 @@ public function execute()
$resultJson = $this->resultJsonFactory->create();
try {
$this->config->deleteConfig(\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_JS_URL, $scope, $scopeId);
- } catch(ValidatorException $e) {
+ } catch (ValidatorException $e) {
$valid = 0;
$message = $e->getMessage();
}
@@ -82,6 +69,7 @@ public function execute()
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/GetInterest.php b/Controller/Adminhtml/Ecommerce/GetInterest.php
index 7850f5e8..00848fb8 100644
--- a/Controller/Adminhtml/Ecommerce/GetInterest.php
+++ b/Controller/Adminhtml/Ecommerce/GetInterest.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/23/18 10:05 AM
- * @file: GetInterest.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Ecommerce;
@@ -33,7 +22,6 @@ class GetInterest extends Action
protected $_storeManager;
/**
- * GetInterest constructor.
* @param Context $context
* @param \Magento\Store\Model\StoreManager $storeManager
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -43,11 +31,10 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
}
/**
@@ -60,7 +47,7 @@ public function execute()
$error = 0;
if (array_key_exists('apikey', $param) && array_key_exists('list', $param)) {
$apiKey = $param['apikey'];
- $list = $param['list'];
+ $list = $param['list'];
$encrypt = $param['encrypt'];
try {
if ($encrypt == 3) {
@@ -69,7 +56,7 @@ public function execute()
$api = $this->_helper->getApiByApiKey($apiKey, $encrypt);
}
- $result = $api->lists->interestCategory->getAll($list, null, null,200);
+ $result = $api->lists->interestCategory->getAll($list, null, null, 200);
if (is_array($result['categories']) && count($result['categories'])) {
$rc = $result['categories'];
}
@@ -80,6 +67,7 @@ public function execute()
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData(['error' => $error, 'data' => $rc]);
+
return $resultJson;
}
diff --git a/Controller/Adminhtml/Ecommerce/Getaccountdetails.php b/Controller/Adminhtml/Ecommerce/Getaccountdetails.php
index b75b451e..177a53ab 100644
--- a/Controller/Adminhtml/Ecommerce/Getaccountdetails.php
+++ b/Controller/Adminhtml/Ecommerce/Getaccountdetails.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/5/17 3:40 PM
- * @file: GetAccountDetails.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Ecommerce;
@@ -33,7 +22,6 @@ class Getaccountdetails extends Action
protected $_storeManager;
/**
- * Getaccountdetails constructor.
* @param Context $context
* @param \Magento\Store\Model\StoreManager $storeManager
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -43,17 +31,17 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
}
+
public function execute()
{
$param = $this->getRequest()->getParams();
$apiKey = $param['apikey'];
- $store = $param['store'];
+ $store = $param['store'];
$encrypt = $param['encrypt'];
try {
if ($encrypt == 3) {
@@ -65,25 +53,45 @@ public function execute()
$options = [];
if (isset($apiInfo['account_name'])) {
$options['username'] = ['label' => __('User name:'), 'value' => $apiInfo['account_name']];
- $options['total_subscribers'] = ['label' => __('Total Account Subscribers:'), 'value' => $apiInfo['total_subscribers']];
+ $options['total_subscribers'] = [
+ 'label' => __('Total Account Subscribers:'),
+ 'value' => $apiInfo['total_subscribers']
+ ];
if ($store != -1) {
$storeData = $api->ecommerce->stores->get($store);
$options['list_id'] = $storeData['list_id'];
$list = $api->lists->getLists($storeData['list_id']);
$options['list_name'] = $list['name'];
- $options['total_list_subscribers'] = ['label' => __('Total List Subscribers:'), 'value' => $list['stats']['member_count']];
+ $options['total_list_subscribers'] = [
+ 'label' => __('Total List Subscribers:'),
+ 'value' => $list['stats']['member_count']
+ ];
$options['subtitle'] = ['label' => __('Ecommerce Data uploaded to MailChimp:'), 'value' => ''];
$totalCustomers = $api->ecommerce->customers->getAll($store, 'total_items');
- $options['total_customers'] = ['label' => __('Total customers:'), 'value' => $totalCustomers['total_items']];
+ $options['total_customers'] = [
+ 'label' => __('Total customers:'),
+ 'value' => $totalCustomers['total_items']
+ ];
$totalProducts = $api->ecommerce->products->getAll($store, 'total_items');
- $options['total_products'] = ['label' => __('Total products:'), 'value' => $totalProducts['total_items']];
+ $options['total_products'] = [
+ 'label' => __('Total products:'),
+ 'value' => $totalProducts['total_items']
+ ];
$totalOrders = $api->ecommerce->orders->getAll($store, 'total_items');
$options['total_orders'] = ['label' => __('Total orders:'), 'value' => $totalOrders['total_items']];
$totalCarts = $api->ecommerce->carts->getAll($store, 'total_items');
$options['total_carts'] = ['label' => __('Total Carts:'), 'value' => $totalCarts['total_items']];
- $options['notsaved'] = ['label' => __('Ecommerce disabled, save configuration to enable'), 'value' => ''];
+ $options['notsaved'] = [
+ 'label' => __('Ecommerce disabled, save configuration to enable'),
+ 'value' => ''
+ ];
} else {
- $options['nostore'] = ['label' => __('Ecommerce disabled, only subscribers will be synchronized (your orders, products,etc will be not synchronized)'), 'value' => ''];
+ $options['nostore'] = [
+ 'label' => __(
+ 'Ecommerce disabled, only subscribers will be synchronized (your orders, products,etc will be not synchronized)'
+ ),
+ 'value' => ''
+ ];
}
}
} catch (\Mailchimp_Error $e) {
@@ -93,8 +101,10 @@ public function execute()
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($options);
+
return $resultJson;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php b/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php
index bcd00905..72e44088 100644
--- a/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php
+++ b/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php
@@ -1,22 +1,10 @@
- * @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\Helper\Sync as SyncHelper;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\ValidatorException;
-use Symfony\Component\Config\Definition\Exception\Exception;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class ResetLocalErrors extends \Magento\Backend\App\Action
{
@@ -51,12 +39,11 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->storeManager = $storeManagerInterface;
- $this->syncHelper = $syncHelper;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->storeManager = $storeManagerInterface;
+ $this->syncHelper = $syncHelper;
}
public function execute()
@@ -93,11 +80,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php b/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php
index 838cd4ec..1089fa85 100644
--- a/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php
+++ b/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php
@@ -1,22 +1,10 @@
- * @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\Helper\Sync as SyncHelper;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\ValidatorException;
-use Symfony\Component\Config\Definition\Exception\Exception;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class ResetLocalErrorsNoRetry extends \Magento\Backend\App\Action
{
@@ -51,12 +39,11 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->storeManager = $storeManagerInterface;
- $this->syncHelper = $syncHelper;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->storeManager = $storeManagerInterface;
+ $this->syncHelper = $syncHelper;
}
public function execute()
@@ -93,11 +80,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/ResetStore.php b/Controller/Adminhtml/Ecommerce/ResetStore.php
index 2a45252d..6d1bcc51 100644
--- a/Controller/Adminhtml/Ecommerce/ResetStore.php
+++ b/Controller/Adminhtml/Ecommerce/ResetStore.php
@@ -1,21 +1,9 @@
- * @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 ResetStore extends \Magento\Backend\App\Action
{
@@ -33,7 +21,6 @@ class ResetStore extends \Magento\Backend\App\Action
protected $storeManager;
/**
- * ResetLocalErrors constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param JsonFactory $resultJsonFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface
@@ -45,11 +32,10 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->helper = $helper;
- $this->storeManager = $storeManagerInterface;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->helper = $helper;
+ $this->storeManager = $storeManagerInterface;
}
public function execute()
@@ -82,11 +68,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/ResyncProducts.php b/Controller/Adminhtml/Ecommerce/ResyncProducts.php
index d68d83f2..a14fb1ef 100644
--- a/Controller/Adminhtml/Ecommerce/ResyncProducts.php
+++ b/Controller/Adminhtml/Ecommerce/ResyncProducts.php
@@ -1,22 +1,10 @@
- * @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\Helper\Sync as SyncHelper;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\ValidatorException;
-use Symfony\Component\Config\Definition\Exception\Exception;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class ResyncProducts extends \Magento\Backend\App\Action
{
@@ -46,9 +34,9 @@ public function __construct(
SyncHelper $syncHelper
) {
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->storeManager = $storeManagerInterface;
- $this->syncHelper = $syncHelper;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->storeManager = $storeManagerInterface;
+ $this->syncHelper = $syncHelper;
}
public function execute()
@@ -64,11 +52,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Ecommerce/ResyncSubscribers.php b/Controller/Adminhtml/Ecommerce/ResyncSubscribers.php
index 9e5a43da..a2674992 100644
--- a/Controller/Adminhtml/Ecommerce/ResyncSubscribers.php
+++ b/Controller/Adminhtml/Ecommerce/ResyncSubscribers.php
@@ -1,22 +1,10 @@
- * @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\Helper\Sync as SyncHelper;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\ValidatorException;
-use Symfony\Component\Config\Definition\Exception\Exception;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class ResyncSubscribers extends \Magento\Backend\App\Action
{
@@ -45,11 +33,10 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
SyncHelper $syncHelper
) {
-
parent::__construct($context);
- $this->resultJsonFactory = $resultJsonFactory;
- $this->storeManager = $storeManagerInterface;
- $this->syncHelper = $syncHelper;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->storeManager = $storeManagerInterface;
+ $this->syncHelper = $syncHelper;
}
public function execute()
@@ -65,11 +52,13 @@ public function execute()
$valid = 0;
$message = $e->getMessage();
}
+
return $resultJson->setData([
'valid' => (int)$valid,
'message' => $message,
]);
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Errors/Getresponse.php b/Controller/Adminhtml/Errors/Getresponse.php
index 9e5c54df..afcd2f6b 100644
--- a/Controller/Adminhtml/Errors/Getresponse.php
+++ b/Controller/Adminhtml/Errors/Getresponse.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/3/17 3:28 PM
- * @file: Getresponse.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Errors;
@@ -40,7 +29,6 @@ class Getresponse extends \Magento\Backend\App\Action
protected $_driver;
/**
- * Getresponse constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $errorsFactory
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -55,16 +43,16 @@ public function __construct(
\Magento\Framework\Filesystem\Driver\File $driver
) {
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_errorsFactory = $errorsFactory;
- $this->_result = $result;
- $this->_helper = $helper;
- $this->_driver = $driver;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_errorsFactory = $errorsFactory;
+ $this->_result = $result;
+ $this->_helper = $helper;
+ $this->_driver = $driver;
}
public function execute()
{
- $errorId = $this->getRequest()->getParam('id');
+ $errorId = $this->getRequest()->getParam('id');
$errors = $this->_errorsFactory->create();
$errors->getResource()->load($errors, $errorId);
$batchId = $errors->getBatchId();
@@ -73,7 +61,7 @@ public function execute()
do {
$counter++;
$files = $this->_result->getBatchResponse($batchId, $errors->getStoreId());
- if ($files===false) {
+ if ($files === false) {
$fileContent = "Response was deleted from MailChimp servers";
break;
}
@@ -90,21 +78,25 @@ public function execute()
$this->_driver->deleteFile($file);
}
$baseDir = $this->_helper->getBaseDir();
- if ($this->_driver->isDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- \Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId)) {
+ if ($this->_driver->isDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ \Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
+ )) {
$this->_driver->deleteDirectory(
$baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
\Ebizmarts\MailChimp\Model\Api\Result::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
);
}
- } while (!count($fileContent) && $counter_resultFactory->create(ResultFactory::TYPE_JSON);
- $resultJson->setHeader('Content-disposition', 'attachment; filename='.$batchId.'.json');
+ } while (!count($fileContent) && $counter < self::MAX_RETRIES);
+ $resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
+ $resultJson->setHeader('Content-disposition', 'attachment; filename=' . $batchId . '.json');
$resultJson->setHeader('Content-type', 'application/json');
$data = json_encode($fileContent, JSON_PRETTY_PRINT);
$resultJson->setJsonData($data);
+
return $resultJson;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::error_grid');
diff --git a/Controller/Adminhtml/Errors/Index.php b/Controller/Adminhtml/Errors/Index.php
index fd173348..1b3b53c4 100644
--- a/Controller/Adminhtml/Errors/Index.php
+++ b/Controller/Adminhtml/Errors/Index.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/28/16 4:58 PM
- * @file: Index.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Errors;
class Index extends \Magento\Backend\App\Action
@@ -20,7 +10,6 @@ class Index extends \Magento\Backend\App\Action
protected $resultPageFactory;
/**
- * Index constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
@@ -32,12 +21,15 @@ public function __construct(
parent::__construct($context);
}
+
public function execute()
{
$page = $this->resultPageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Mailchimp Errors'));
+
return $page;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::error_grid');
diff --git a/Controller/Adminhtml/Lists/Get.php b/Controller/Adminhtml/Lists/Get.php
index 8d2f73a6..edee3c75 100644
--- a/Controller/Adminhtml/Lists/Get.php
+++ b/Controller/Adminhtml/Lists/Get.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/20/17 3:20 PM
- * @file: Get.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Lists;
use Magento\Backend\App\Action;
@@ -34,7 +24,6 @@ class Get extends Action
protected $encryptor;
/**
- * Get constructor.
* @param Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\Encryption\Encryptor $encryptor
@@ -44,12 +33,12 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Framework\Encryption\Encryptor $encryptor
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_helper = $helper;
- $this->encryptor = $encryptor;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_helper = $helper;
+ $this->encryptor = $encryptor;
}
+
public function execute()
{
$param = $this->getRequest()->getParams();
@@ -69,8 +58,10 @@ public function execute()
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($result);
+
return $resultJson;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_edit');
diff --git a/Controller/Adminhtml/Orders/Campaign.php b/Controller/Adminhtml/Orders/Campaign.php
index 92a33693..c0e4ca07 100644
--- a/Controller/Adminhtml/Orders/Campaign.php
+++ b/Controller/Adminhtml/Orders/Campaign.php
@@ -2,11 +2,11 @@
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Orders;
+use Ebizmarts\MailChimp\Helper\Data as MailChimpHelper;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\UrlInterface;
use Magento\Sales\Model\OrderRepository;
-use Ebizmarts\MailChimp\Helper\Data as MailChimpHelper;
class Campaign extends Action
{
@@ -40,6 +40,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->urlBuilder = $urlBuilder;
}
+
public function execute()
{
$param = $this->getRequest()->getParams();
@@ -50,12 +51,15 @@ public function execute()
$campaign = $api->campaigns->get($order->getMailchimpCampaignId());
$webId = $campaign['web_id'];
$url = $this->urlBuilder->getUrl('https://admin.mailchimp.com/reports/summary') . "?id=$webId";
+
return $this->_redirect($url);
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
+
return $this->_redirect($this->urlBuilder->getUrl('sales/order'));
}
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::mailchimp_access');
diff --git a/Controller/Adminhtml/Orders/Member.php b/Controller/Adminhtml/Orders/Member.php
index 4ed0f916..227bf0aa 100644
--- a/Controller/Adminhtml/Orders/Member.php
+++ b/Controller/Adminhtml/Orders/Member.php
@@ -2,11 +2,11 @@
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Orders;
+use Ebizmarts\MailChimp\Helper\Data as MailChimpHelper;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\UrlInterface;
use Magento\Sales\Model\OrderRepository;
-use Ebizmarts\MailChimp\Helper\Data as MailChimpHelper;
class Member extends Action
{
@@ -40,6 +40,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->urlBuilder = $urlBuilder;
}
+
public function execute()
{
$param = $this->getRequest()->getParams();
@@ -51,13 +52,18 @@ public function execute()
$listId = $this->helper->getDefaultList($order->getStoreId());
$member = $api->lists->members->get($listId, hash('md5', strtolower($email)));
$memberId = $member['contact_id'];
- $url = $this->urlBuilder->getUrl('https://admin.mailchimp.com/audience/contact-profile') . "?contact_id=$memberId";
+ $url = $this->urlBuilder->getUrl(
+ 'https://admin.mailchimp.com/audience/contact-profile'
+ ) . "?contact_id=$memberId";
+
return $this->_redirect($url);
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
+
return $this->_redirect($this->urlBuilder->getUrl('sales/order'));
}
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::mailchimp_access');
diff --git a/Controller/Adminhtml/Stores.php b/Controller/Adminhtml/Stores.php
index 9e2d9b42..f37b2a80 100644
--- a/Controller/Adminhtml/Stores.php
+++ b/Controller/Adminhtml/Stores.php
@@ -1,23 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/12/17 11:35 AM
- * @file: Stores.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml;
+use Ebizmarts\MailChimp\Model\MailChimpStoresFactory;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
-use Ebizmarts\MailChimp\Model\MailChimpStoresFactory;
class Stores extends Action
{
@@ -39,7 +28,6 @@ class Stores extends Action
protected $_mhelper;
/**
- * Stores constructor.
* @param Context $context
* @param Registry $registry
* @param PageFactory $resultPageFactory
@@ -53,17 +41,18 @@ public function __construct(
MailChimpStoresFactory $storesFactory,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->_coreRegistry = $registry;
- $this->_resultPageFactory = $resultPageFactory;
- $this->_mailchimpStoresFactory = $storesFactory;
- $this->_mhelper = $helper;
+ $this->_coreRegistry = $registry;
+ $this->_resultPageFactory = $resultPageFactory;
+ $this->_mailchimpStoresFactory = $storesFactory;
+ $this->_mhelper = $helper;
}
+
public function execute()
{
return 1;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_grid');
diff --git a/Controller/Adminhtml/Stores/Delete.php b/Controller/Adminhtml/Stores/Delete.php
index b325b3e1..5c508dc2 100644
--- a/Controller/Adminhtml/Stores/Delete.php
+++ b/Controller/Adminhtml/Stores/Delete.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/17/17 12:03 PM
- * @file: Delete.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
@@ -18,7 +7,7 @@ class Delete extends \Ebizmarts\MailChimp\Controller\Adminhtml\Stores
public function execute()
{
$resultRedirect = $this->resultRedirectFactory->create();
- $storeId = (int) $this->getRequest()->getParam('id');
+ $storeId = (int)$this->getRequest()->getParam('id');
if ($storeId) {
$storeModel = $this->_mailchimpStoresFactory->create();
$storeModel->getResource()->load($storeModel, $storeId);
@@ -26,14 +15,17 @@ public function execute()
$api = $this->_mhelper->getApiByApiKey($storeModel->getApikey(), true);
$api->ecommerce->stores->delete($storeModel->getStoreid());
$this->messageManager->addSuccess(__('You deleted the store.'));
+
return $resultRedirect->setPath('mailchimp/stores');
} catch (\Mailchimp_Error $e) {
- $this->messageManager->addError(__('Store could not be deleted.'.$e->getMessage()));
+ $this->messageManager->addError(__('Store could not be deleted.' . $e->getMessage()));
$this->_mhelper->log($e->getFriendlyMessage());
- return $resultRedirect->setPath('mailchimp/stores/edit', ['id'=>$storeId]);
+
+ return $resultRedirect->setPath('mailchimp/stores/edit', ['id' => $storeId]);
}
}
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_edit');
diff --git a/Controller/Adminhtml/Stores/Edit.php b/Controller/Adminhtml/Stores/Edit.php
index d21e9fd3..cf48405c 100644
--- a/Controller/Adminhtml/Stores/Edit.php
+++ b/Controller/Adminhtml/Stores/Edit.php
@@ -1,23 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/5/17 1:23 PM
- * @file: Edit.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
-use Ebizmarts\MailChimp\Model\MailChimpStoresFactory;
-use Magento\Backend\App\Action\Context;
-use Magento\Framework\Registry;
-use Magento\Framework\View\Result\PageFactory;
-
class Edit extends \Ebizmarts\MailChimp\Controller\Adminhtml\Stores
{
@@ -32,6 +16,7 @@ public function execute()
if (!$model->getId()) {
$this->messageManager->addError(__('This store no longer exists.'));
$this->_redirect('*/*/');
+
return;
}
}
@@ -56,6 +41,7 @@ public function execute()
return $resultPage;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_edit');
diff --git a/Controller/Adminhtml/Stores/Get.php b/Controller/Adminhtml/Stores/Get.php
index 3716546a..66af24e9 100644
--- a/Controller/Adminhtml/Stores/Get.php
+++ b/Controller/Adminhtml/Stores/Get.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/20/17 3:20 PM
- * @file: Get.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
use Magento\Backend\App\Action;
@@ -30,7 +20,6 @@ class Get extends Action
protected $_resultFactory;
/**
- * Get constructor.
* @param Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
*/
@@ -38,11 +27,11 @@ public function __construct(
Context $context,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_mhelper = $helper;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_mhelper = $helper;
}
+
public function execute()
{
$param = $this->getRequest()->getParams();
@@ -56,7 +45,7 @@ public function execute()
$result['stores'] = [];
foreach ($stores['stores'] as $store) {
if ($store['platform'] == \Ebizmarts\MailChimp\Helper\Data::PLATFORM) {
- if ($store['list_id']=='') {
+ if ($store['list_id'] == '') {
continue;
}
$list = $api->lists->getLists($store['list_id']);
@@ -76,8 +65,10 @@ public function execute()
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($result);
+
return $resultJson;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
diff --git a/Controller/Adminhtml/Stores/Index.php b/Controller/Adminhtml/Stores/Index.php
index af995c42..09269ffe 100644
--- a/Controller/Adminhtml/Stores/Index.php
+++ b/Controller/Adminhtml/Stores/Index.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/24/17 10:38 AM
- * @file: Index.php
- */
+
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
use Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
@@ -21,8 +11,10 @@ public function execute()
$this->_mhelper->loadStores();
$page = $this->_resultPageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Mailchimp Stores'));
+
return $page;
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_grid');
diff --git a/Controller/Adminhtml/Stores/Save.php b/Controller/Adminhtml/Stores/Save.php
index 5e67c32c..9720acb2 100644
--- a/Controller/Adminhtml/Stores/Save.php
+++ b/Controller/Adminhtml/Stores/Save.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/17/17 11:05 AM
- * @file: Save.php
- */
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores;
@@ -36,37 +25,40 @@ public function execute()
if (!$storeId) {
$storeId = $storeModel->getId();
}
- return $resultRedirect->setPath('mailchimp/stores/edit', ['id'=>$storeId]);
+
+ return $resultRedirect->setPath('mailchimp/stores/edit', ['id' => $storeId]);
} else {
return $resultRedirect->setPath('mailchimp/stores');
}
} catch (\Mailchimp_Error $e) {
- $this->messageManager->addErrorMessage(__('Store could not be saved.'.$e->getMessage()));
+ $this->messageManager->addErrorMessage(__('Store could not be saved.' . $e->getMessage()));
$this->_mhelper->log($e->getFriendlyMessage());
- return $resultRedirect->setPath('mailchimp/stores/edit', ['id'=>$storeId]);
+
+ return $resultRedirect->setPath('mailchimp/stores/edit', ['id' => $storeId]);
}
}
}
+
protected function _updateMailchimp($formData)
{
$api = $this->_mhelper->getApiByApiKey($formData['apikey'], true);
// set the address
$address = [];
- $address['address1'] = $formData['address_address_one'];
- $address['address2'] = $formData['address_address_two'];
- $address['city'] = $formData['address_city'];
- $address['province'] = '';
+ $address['address1'] = $formData['address_address_one'];
+ $address['address2'] = $formData['address_address_two'];
+ $address['city'] = $formData['address_city'];
+ $address['province'] = '';
$address['province_code'] = '';
$address['postal_code'] = $formData['address_postal_code'];
- $address['country'] = '';
+ $address['country'] = '';
$address['country_code'] = $formData['address_country_code'];
- $emailAddress = $formData['email_address'];
- $currencyCode = $formData['currency_code'];
- $primaryLocale = $formData['primary_locale'];
- $timeZone = $formData['timezone'];
- $phone = $formData['phone'];
- $name = $formData['name'];
- $domain = $formData['domain'];
+ $emailAddress = $formData['email_address'];
+ $currencyCode = $formData['currency_code'];
+ $primaryLocale = $formData['primary_locale'];
+ $timeZone = $formData['timezone'];
+ $phone = $formData['phone'];
+ $name = $formData['name'];
+ $domain = $formData['domain'];
$storeId = isset($formData['storeid']) ? $formData['storeid'] : null;
$is_sync = null;
@@ -87,10 +79,10 @@ protected function _updateMailchimp($formData)
);
} else {
$date = $this->_mhelper->getDateMicrotime();
- $mailchimpStoreId = hash('md5', $name. '_' . $date);
+ $mailchimpStoreId = hash('md5', $name . '_' . $date);
//$mailchimpStoreId = md5($name. '_' . $date);
$is_sync = true;
- $ret =$api->ecommerce->stores->add(
+ $ret = $api->ecommerce->stores->add(
$mailchimpStoreId,
$formData['list_id'],
$name,
@@ -107,8 +99,10 @@ protected function _updateMailchimp($formData)
);
$formData['storeid'] = $mailchimpStoreId;
}
+
return $formData['storeid'];
}
+
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_edit');
diff --git a/Controller/Campaign/Check.php b/Controller/Campaign/Check.php
index 43d74804..e75de89d 100644
--- a/Controller/Campaign/Check.php
+++ b/Controller/Campaign/Check.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 1/19/19 12:36 PM
- * @file: Check.php
- */
namespace Ebizmarts\MailChimp\Controller\Campaign;
@@ -29,7 +18,6 @@ class Check extends \Magento\Framework\App\Action\Action
protected $_storeManager;
/**
- * Get constructor.
* @param Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
*/
@@ -38,11 +26,10 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
}
public function execute()
@@ -54,7 +41,7 @@ public function execute()
$magentoStoreId = $this->_storeManager->getStore()->getId();
$api = $this->_helper->getApi($magentoStoreId);
try {
- $campaign =$api->campaigns->get($mc_cid);
+ $campaign = $api->campaigns->get($mc_cid);
$mailchimpList = $this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$magentoStoreId
@@ -72,6 +59,7 @@ public function execute()
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData(['valid' => $valid]);
+
return $resultJson;
}
}
diff --git a/Controller/Cart/Loadquote.php b/Controller/Cart/Loadquote.php
index a6507bd1..047e5f4a 100644
--- a/Controller/Cart/Loadquote.php
+++ b/Controller/Cart/Loadquote.php
@@ -1,18 +1,11 @@
pageFactory = $pageFactory;
- $this->_quote = $quote;
+ $this->pageFactory = $pageFactory;
+ $this->_quote = $quote;
$this->_customerSession = $customerSession;
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_urlHelper = $urlHelper;
- $this->_message = $context->getMessageManager();
- $this->_customerUrl = $customerUrl;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_urlHelper = $urlHelper;
+ $this->_message = $context->getMessageManager();
+ $this->_customerUrl = $customerUrl;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context);
}
/**
* Index Action
- *
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
/** @var \Magento\Framework\View\Result\Page $resultPage */
$resultPage = $this->pageFactory->create();
- $params = $this->getRequest()->getParams();
+ $params = $this->getRequest()->getParams();
if (isset($params['id'])) {
$quote = $this->_quote->create();
$quote->getResource()->load($quote, $params['id']);
@@ -128,7 +119,7 @@ public function execute()
\Ebizmarts\MailChimp\Helper\Data::XML_ABANDONEDCART_PAGE,
$magentoStoreId
),
- ['mc_cid'=> $params['mc_cid']]
+ ['mc_cid' => $params['mc_cid']]
);
$quote->setData('mailchimp_campaign_id', $params['mc_cid']);
} else {
@@ -153,7 +144,7 @@ public function execute()
if (isset($params['mc_cid'])) {
$url = $this->_urlHelper->getUrl(
$this->_customerUrl->getLoginUrl(),
- ['mc_cid'=>$params['mc_cid']]
+ ['mc_cid' => $params['mc_cid']]
);
} else {
$url = $this->_customerUrl->getLoginUrl();
@@ -163,6 +154,7 @@ public function execute()
}
}
}
+
return $resultPage;
}
}
diff --git a/Controller/Checkout/Success.php b/Controller/Checkout/Success.php
index 8a7ba4cd..0d8e5bf1 100644
--- a/Controller/Checkout/Success.php
+++ b/Controller/Checkout/Success.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/20/17 5:06 PM
- * @file: Success.php
- */
namespace Ebizmarts\MailChimp\Controller\Checkout;
@@ -60,19 +49,18 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
SyncHelper $syncHelper
) {
-
- $this->_pageFactory =$pageFactory;
- $this->_helper = $helper;
- $this->_checkoutSession = $checkoutSession;
- $this->_subscriberFactory = $subscriberFactory;
- $this->_interestGroupFactory= $interestGroupFactory;
- $this->syncHelper = $syncHelper;
+ $this->_pageFactory = $pageFactory;
+ $this->_helper = $helper;
+ $this->_checkoutSession = $checkoutSession;
+ $this->_subscriberFactory = $subscriberFactory;
+ $this->_interestGroupFactory = $interestGroupFactory;
+ $this->syncHelper = $syncHelper;
parent::__construct($context);
}
public function execute()
{
- $params = $this->getRequest()->getParams();
+ $params = $this->getRequest()->getParams();
$order = $this->_checkoutSession->getLastRealOrder();
/**
* @var $subscriber \Magento\Newsletter\Model\Subscriber
@@ -82,8 +70,8 @@ public function execute()
$interestGroup = $this->_interestGroupFactory->create();
try {
$subscriber->loadBySubscriberEmail($order->getCustomerEmail(), $order->getStoreId());
- if ($subscriber->getEmail()==$order->getCustomerEmail()) {
- if ($subscriber->getStatus()==\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
+ if ($subscriber->getEmail() == $order->getCustomerEmail()) {
+ if ($subscriber->getStatus() == \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
$subscriber->subscribe($subscriber->getEmail());
}
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
@@ -109,11 +97,14 @@ public function execute()
}
$this->messageManager->addSuccessMessage(__('Thanks for sharing your interest with us'));
- return $this->_redirect($this->_helper->getBaserUrl(
- $order->getStoreId(),
- \Magento\Framework\UrlInterface::URL_TYPE_WEB
- ));
+ return $this->_redirect(
+ $this->_helper->getBaserUrl(
+ $order->getStoreId(),
+ \Magento\Framework\UrlInterface::URL_TYPE_WEB
+ )
+ );
}
+
protected function _updateSubscriber(
$listId,
$entityId,
diff --git a/Controller/WebHook/Index.php b/Controller/WebHook/Index.php
index 9bb6131a..a6395024 100644
--- a/Controller/WebHook/Index.php
+++ b/Controller/WebHook/Index.php
@@ -1,25 +1,13 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/23/17 3:36 PM
- * @file: Index.php
- */
namespace Ebizmarts\MailChimp\Controller\WebHook;
use Magento\Framework\App\Action\Action;
-use Magento\Framework\Controller\ResultFactory;
-use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
class Index extends Action implements CsrfAwareActionInterface
@@ -40,7 +28,6 @@ class Index extends Action implements CsrfAwareActionInterface
private $_remoteAddress;
/**
- * Index constructor.
* @param Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\MailChimpWebhookRequestFactory $chimpWebhookRequestFactory
@@ -52,13 +39,13 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpWebhookRequestFactory $chimpWebhookRequestFactory,
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
) {
-
parent::__construct($context);
- $this->_resultFactory = $context->getResultFactory();
- $this->_helper = $helper;
- $this->_chimpWebhookRequestFactory = $chimpWebhookRequestFactory;
- $this->_remoteAddress = $remoteAddress;
+ $this->_resultFactory = $context->getResultFactory();
+ $this->_helper = $helper;
+ $this->_chimpWebhookRequestFactory = $chimpWebhookRequestFactory;
+ $this->_remoteAddress = $remoteAddress;
}
+
/**
* @inheritDoc
*/
@@ -67,6 +54,7 @@ public function createCsrfValidationException(
): ?InvalidRequestException {
return null;
}
+
/**
* @inheritDoc
*/
@@ -84,20 +72,22 @@ public function execute()
$result = $this->_resultFactory->create(ResultFactory::TYPE_RAW);
$result->setContents('');
if (!$requestKey) {
- $this->_helper->log('No wkey parameter from ip: '.$this->_remoteAddress->getRemoteAddress());
+ $this->_helper->log('No wkey parameter from ip: ' . $this->_remoteAddress->getRemoteAddress());
$result->setHttpResponseCode(403);
+
return $result;
}
$key = $this->_helper->getWebhooksKey();
- if ($key!=$requestKey) {
- $this->_helper->log('wkey parameter is invalid from ip: '.$this->_remoteAddress->getRemoteAddress());
+ if ($key != $requestKey) {
+ $this->_helper->log('wkey parameter is invalid from ip: ' . $this->_remoteAddress->getRemoteAddress());
$result->setHttpResponseCode(403);
+
return $result;
}
if ($this->getRequest()->getPost('type')) {
$request = $this->getRequest()->getPost();
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_WEBHOOK_ACTIVE) ||
- $request['type']==\Ebizmarts\MailChimp\Cron\Webhook::TYPE_SUBSCRIBE) {
+ $request['type'] == \Ebizmarts\MailChimp\Cron\Webhook::TYPE_SUBSCRIBE) {
try {
$chimpRequest = $this->_chimpWebhookRequestFactory->create();
$chimpRequest->setType($request['type']);
@@ -106,16 +96,17 @@ public function execute()
$chimpRequest->setProcessed(false);
$chimpRequest->getResource()->save($chimpRequest);
$result->setHttpResponseCode(200);
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->_helper->log($e->getMessage());
$this->_helper->log($request['data']);
$result->setHttpResponseCode(403);
}
}
} else {
- $this->_helper->log('An empty request comes from ip: '.$this->_remoteAddress->getRemoteAddress());
+ $this->_helper->log('An empty request comes from ip: ' . $this->_remoteAddress->getRemoteAddress());
$result->setHttpResponseCode(200);
}
+
return $result;
}
}
diff --git a/Cron/BatchesClean.php b/Cron/BatchesClean.php
index 1c0d16fc..ae19de09 100644
--- a/Cron/BatchesClean.php
+++ b/Cron/BatchesClean.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 22/11/18 10:02 AM
- * @file: BatchesClean.php
- */
+
namespace Ebizmarts\MailChimp\Cron;
class BatchesClean
@@ -28,7 +18,6 @@ class BatchesClean
protected $mailChimpErrors;
/**
- * BatchesClean constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncBatches $mailChimpSyncBatches
* @param \Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors
@@ -38,10 +27,11 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpSyncBatches $mailChimpSyncBatches,
\Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors
) {
- $this->helper = $helper;
+ $this->helper = $helper;
$this->mailChimpSyncBatches = $mailChimpSyncBatches;
- $this->mailChimpErrors = $chimpErrors;
+ $this->mailChimpErrors = $chimpErrors;
}
+
public function execute()
{
try {
diff --git a/Cron/Ecommerce.php b/Cron/Ecommerce.php
index 2d585ba8..6dacd2e3 100644
--- a/Cron/Ecommerce.php
+++ b/Cron/Ecommerce.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/1/16 10:02 AM
- * @file: Ecommerce.php
- */
namespace Ebizmarts\MailChimp\Cron;
@@ -69,7 +58,6 @@ class Ecommerce
private $_dir;
/**
- * Ecommerce constructor.
* @param \Magento\Store\Model\StoreManager $storeManager
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\Api\Product $apiProduct
@@ -99,25 +87,23 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSyncEcommerce,
\Magento\Framework\Filesystem\DirectoryList $dir
) {
-
- $this->_storeManager = $storeManager;
- $this->_helper = $helper;
- $this->_apiProduct = $apiProduct;
+ $this->_storeManager = $storeManager;
+ $this->_helper = $helper;
+ $this->_apiProduct = $apiProduct;
$this->_mailChimpSyncBatchesFactory = $mailChimpSyncBatchesFactory;
- $this->_apiResult = $apiResult;
- $this->_apiCustomer = $apiCustomer;
- $this->_apiOrder = $apiOrder;
- $this->_apiCart = $apiCart;
- $this->_apiSubscribers = $apiSubscriber;
- $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
- $this->_apiPromoCodes = $apiPromoCodes;
- $this->_apiPromoRules = $apiPromoRules;
- $this->_dir = $dir;
+ $this->_apiResult = $apiResult;
+ $this->_apiCustomer = $apiCustomer;
+ $this->_apiOrder = $apiOrder;
+ $this->_apiCart = $apiCart;
+ $this->_apiSubscribers = $apiSubscriber;
+ $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
+ $this->_apiPromoCodes = $apiPromoCodes;
+ $this->_apiPromoRules = $apiPromoRules;
+ $this->_dir = $dir;
}
public function execute()
{
-
$connection = $this->_chimpSyncEcommerce->getResource()->getConnection();
$tableName = $this->_chimpSyncEcommerce->getResource()->getMainTable();
$connection->delete(
@@ -129,6 +115,7 @@ public function execute()
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $storeId)) {
if (!$this->_ping($storeId)) {
$this->_helper->log('MailChimp is not available');
+
return;
}
$this->_storeManager->setCurrentStore($storeId);
@@ -155,7 +142,8 @@ public function execute()
[
'batch_id' => $batchId,
'mailchimp_sync_modified' => 0,
- 'mailchimp_sync_delta' => $this->_helper->getGmtDate()],
+ 'mailchimp_sync_delta' => $this->_helper->getGmtDate()
+ ],
"batch_id is null and mailchimp_store_id = '$listId' and mailchimp_sync_error is null"
);
}
@@ -188,10 +176,10 @@ public function execute()
}
foreach ($syncs as $mailchimpStoreId => $val) {
if ($val && !$this->_helper->getConfigValue(
- \Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC . "/$mailchimpStoreId",
- 0,
- 'default'
- )
+ \Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC . "/$mailchimpStoreId",
+ 0,
+ 'default'
+ )
) {
$this->updateSyncFlagData($val['storeid'], $mailchimpStoreId);
}
@@ -242,10 +230,9 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId)
}
if (!empty($results)) {
- list($OKOperations, $BadOperations) = $this->encodeOperations($results);
+ [$OKOperations, $BadOperations] = $this->encodeOperations($results);
$batchArray['operations'] = $OKOperations;
try {
-
if (!count($batchArray['operations'])) {
$this->_helper->log('An empty operation was detected');
} else {
@@ -266,9 +253,15 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId)
$syncBatches->setCustomersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_NEW]);
$syncBatches->setCartsNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::QUO_NEW]);
$syncBatches->setOrdersNewCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::ORD_NEW]);
- $syncBatches->setSubscribersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::SUB_MOD]);
- $syncBatches->setProductsModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::PRO_MOD]);
- $syncBatches->setCustomersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_MOD]);
+ $syncBatches->setSubscribersModifiedCount(
+ $batchCounters[\Ebizmarts\MailChimp\Helper\Data::SUB_MOD]
+ );
+ $syncBatches->setProductsModifiedCount(
+ $batchCounters[\Ebizmarts\MailChimp\Helper\Data::PRO_MOD]
+ );
+ $syncBatches->setCustomersModifiedCount(
+ $batchCounters[\Ebizmarts\MailChimp\Helper\Data::CUS_MOD]
+ );
$syncBatches->setCartsModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::QUO_MOD]);
$syncBatches->setOrdersModifiedCount($batchCounters[\Ebizmarts\MailChimp\Helper\Data::ORD_MOD]);
$syncBatches->getResource()->save($syncBatches);
@@ -279,7 +272,6 @@ protected function _processStore($storeId, $mailchimpStoreId, $listId)
if (count($BadOperations)) {
$this->markWithError($BadOperations, $mailchimpStoreId, $listId);
}
-
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
} catch (\Exception $e) {
@@ -343,6 +335,7 @@ protected function apiUpdateSyncFlag($storeId, $mailchimpStoreId)
$this->_helper->log($e->getFriendlyMessage());
}
}
+
protected function _ping($storeId)
{
try {
@@ -350,10 +343,13 @@ protected function _ping($storeId)
$api->root->info();
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
+
return false;
}
+
return true;
}
+
protected function _showResume($batchId, $storeId)
{
$this->_helper->log("Sent batch $batchId for store $storeId");
@@ -362,7 +358,8 @@ protected function _showResume($batchId, $storeId)
protected function _saveRequest($resquest)
{
- $pathLog = $this->_dir->getPath('log').DIRECTORY_SEPARATOR.'Request'.$this->_helper->getGmtTimeStamp().'.log';
+ $pathLog = $this->_dir->getPath('log') . DIRECTORY_SEPARATOR . 'Request' . $this->_helper->getGmtTimeStamp(
+ ) . '.log';
error_log(var_export($resquest, true), 3, $pathLog);
$this->_helper->log("Request with error was saved in $pathLog");
}
@@ -372,7 +369,7 @@ protected function encodeOperations($operations)
$OKOperations = [];
$BadOperations = [];
$batchJson = json_encode($operations);
- $jsonLastErrorGeneral = json_last_error();
+ $jsonLastErrorGeneral = json_last_error();
$jsonLastErrorMsgGeneral = json_last_error_msg();
if ($jsonLastErrorGeneral) {
$this->_helper->log("Encode error");
@@ -394,8 +391,10 @@ protected function encodeOperations($operations)
} else {
$OKOperations = $operations;
}
+
return [$OKOperations, $BadOperations];
}
+
protected function markWithError($operations, $mailchimpStoreId, $listId)
{
$type = null;
@@ -433,11 +432,11 @@ protected function markWithError($operations, $mailchimpStoreId, $listId)
$connection->update(
$tableName,
[
- 'batch_id' => -1,
- 'mailchimp_sync_modified' => 0,
- 'mailchimp_sync_delta' => $this->_helper->getGmtDate(),
- 'mailchimp_sync_error' => __('Json error'),
- 'mailchimp_sent' => \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED
+ 'batch_id' => -1,
+ 'mailchimp_sync_modified' => 0,
+ 'mailchimp_sync_delta' => $this->_helper->getGmtDate(),
+ 'mailchimp_sync_error' => __('Json error'),
+ 'mailchimp_sent' => \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED
],
"batch_id is null and mailchimp_store_id = '$storeId' and type ='$type' and related_id = $relatedId"
);
diff --git a/Cron/ErrorsClean.php b/Cron/ErrorsClean.php
index 16136682..dd02dc6d 100644
--- a/Cron/ErrorsClean.php
+++ b/Cron/ErrorsClean.php
@@ -1,16 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 15/09/22 10:02 AM
- * @file: ErrorsClean.php
- */
namespace Ebizmarts\MailChimp\Cron;
class ErrorsClean
@@ -38,25 +27,24 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors,
\Magento\Store\Model\StoreManager $storeManager
- )
- {
+ ) {
$this->helper = $helper;
$this->chimpErrors = $chimpErrors;
$this->storeManager = $storeManager;
}
+
public function execute()
{
- foreach ($this->storeManager->getStores() as $storeId => $val)
- {
+ foreach ($this->storeManager->getStores() as $storeId => $val) {
$period = $this->helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_CLEAN_ERROR_MONTHS, $storeId);
if ($period > 0) {
try {
$this->helper->log("Cleaning errors for store [$storeId] older than $period months");
- $this->chimpErrors->deleteByStorePeriod($storeId,$period,self::LIMIT);
+ $this->chimpErrors->deleteByStorePeriod($storeId, $period, self::LIMIT);
} catch (\Exception $e) {
$this->helper->log($e->getMessage());
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Cron/Webhook.php b/Cron/Webhook.php
index 66ac8b41..080174d0 100644
--- a/Cron/Webhook.php
+++ b/Cron/Webhook.php
@@ -1,35 +1,23 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/30/17 8:34 PM
- * @file: Webhook.php
- */
namespace Ebizmarts\MailChimp\Cron;
-
class Webhook
{
- const ACTION_DELETE = 'delete';
- const ACTION_UNSUBSCRIBE = 'unsub';
+ const ACTION_DELETE = 'delete';
+ const ACTION_UNSUBSCRIBE = 'unsub';
- const TYPE_SUBSCRIBE = 'subscribe';
- const TYPE_UNSUBSCRIBE = 'unsubscribe';
- const TYPE_CLEANED = 'cleaned';
- const TYPE_UPDATE_EMAIL = 'upemail';
- const TYPE_PROFILE = 'profile';
- const BATCH_LIMIT = 50;
- const NOT_PROCESSED = 0;
- const PROCESSED_OK = 1;
- const PROCESSED_WITH_ERROR = 2;
- const DATA_WITH_ERROR = 3;
- const DATA_NOT_CONVERTED = 4;
+ const TYPE_SUBSCRIBE = 'subscribe';
+ const TYPE_UNSUBSCRIBE = 'unsubscribe';
+ const TYPE_CLEANED = 'cleaned';
+ const TYPE_UPDATE_EMAIL = 'upemail';
+ const TYPE_PROFILE = 'profile';
+ const BATCH_LIMIT = 50;
+ const NOT_PROCESSED = 0;
+ const PROCESSED_OK = 1;
+ const PROCESSED_WITH_ERROR = 2;
+ const DATA_WITH_ERROR = 3;
+ const DATA_NOT_CONVERTED = 4;
/**
* @var \Ebizmarts\MailChimp\Helper\Data
*/
@@ -57,7 +45,6 @@ class Webhook
protected $groups = [];
/**
- * Webhook constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
* @param \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest\CollectionFactory $webhookCollection
@@ -73,18 +60,19 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
\Magento\Customer\Model\CustomerFactory $customer
) {
-
- $this->_helper = $helper;
- $this->_subscriberFactory = $subscriberFactory;
- $this->_webhookCollection = $webhookCollection;
- $this->_customer = $customer;
+ $this->_helper = $helper;
+ $this->_subscriberFactory = $subscriberFactory;
+ $this->_webhookCollection = $webhookCollection;
+ $this->_customer = $customer;
$this->interestGroupFactory = $interestGroupFactory;
- $this->storeManager = $storeManager;
+ $this->storeManager = $storeManager;
}
+
public function execute()
{
$this->processWebhooks();
}
+
public function processWebhooks()
{
$this->_loadGroups();
@@ -92,7 +80,7 @@ public function processWebhooks()
* @var $collection \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest\Collection
*/
$collection = $this->_webhookCollection->create();
- $collection->addFieldToFilter('processed', ['eq'=>self::NOT_PROCESSED]);
+ $collection->addFieldToFilter('processed', ['eq' => self::NOT_PROCESSED]);
$collection->getSelect()->limit(self::BATCH_LIMIT);
/**
* @var $item \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest
@@ -130,10 +118,11 @@ public function processWebhooks()
$item->getResource()->save($item);
}
}
+
protected function _subscribe($data)
{
$listId = $data['list_id'];
- $email = $data['email'];
+ $email = $data['email'];
$subscribers = $this->_helper->loadListSubscribers($listId, $email);
/**
* @var $sub \Magento\Newsletter\Model\Subscriber
@@ -161,10 +150,11 @@ protected function _subscribe($data)
}
}
}
+
protected function _unsubscribe($data)
{
$listId = $data['list_id'];
- $email = $data['email'];
+ $email = $data['email'];
$subscribers = $this->_helper->loadListSubscribers($listId, $email);
/**
* @var $sub \Magento\Newsletter\Model\Subscriber
@@ -176,12 +166,13 @@ protected function _unsubscribe($data)
case self::ACTION_DELETE:
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_WEBHOOK_DELETE)) {
$sub->getResource()->delete($sub);
- } elseif ($sub->getSubscriberStatus()!=\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
+ } elseif ($sub->getSubscriberStatus(
+ ) != \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
$this->_subscribeMember($sub, \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED);
}
break;
case self::ACTION_UNSUBSCRIBE:
- if ($sub->getSubscriberStatus()!=\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
+ if ($sub->getSubscriberStatus() != \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
$this->_subscribeMember($sub, \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED);
}
break;
@@ -191,6 +182,7 @@ protected function _unsubscribe($data)
}
}
}
+
protected function _clean($data)
{
$subscribers = $this->_helper->loadListSubscribers($data['list_id'], $data['email']);
@@ -201,11 +193,12 @@ protected function _clean($data)
$sub->getResource()->delete($sub);
}
}
+
protected function _updateEmail($data)
{
$oldEmail = $data['old_email'];
$newEmail = $data['new_email'];
- $listId = $data['list_id'];
+ $listId = $data['list_id'];
$oldSubscribers = $this->_helper->loadListSubscribers($listId, $oldEmail);
$newSubscribers = $this->_helper->loadListSubscribers($listId, $newEmail);
/**
@@ -224,6 +217,7 @@ protected function _updateEmail($data)
}
}
}
+
protected function _profile($data)
{
$listId = $data['list_id'];
@@ -236,7 +230,7 @@ protected function _profile($data)
foreach ($customers as $c) {
$customer = $this->_customer->create();
$customer->getResource()->load($customer, $c->getEntityId());
- $this->_processMerges($customer,$data);
+ $this->_processMerges($customer, $data);
$customer->getResource()->save($customer);
}
} else {
@@ -253,9 +247,15 @@ protected function _profile($data)
$member = $api->lists->members->get($listId, hash('md5', strtolower($email)));
if ($member) {
if ($member['status'] == \Mailchimp::SUBSCRIBED) {
- $this->_subscribeMember($subscriber, \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED);
+ $this->_subscribeMember(
+ $subscriber,
+ \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED
+ );
} elseif ($member['status'] == \Mailchimp::UNSUBSCRIBED) {
- $this->_subscribeMember($subscriber, \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED);
+ $this->_subscribeMember(
+ $subscriber,
+ \Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED
+ );
}
}
} catch (\Mailchimp_Error $e) {
@@ -273,21 +273,27 @@ protected function _profile($data)
protected function _processMerges(\Magento\Customer\Model\Customer $customer, $data)
{
$mapFields = $this->_helper->getMapFields($customer->getStoreId());
- foreach($data['merges'] as $key=> $value) {
+ foreach ($data['merges'] as $key => $value) {
if (!empty($value)) {
- if ($key=='GROUPINGS') {
+ if ($key == 'GROUPINGS') {
$groups = ['group' => []];
- foreach($value as $item) {
+ foreach ($value as $item) {
if (!empty($item['groups'])) {
- $groups['group'][$item['unique_id']] = $this->_getGroups($item['groups'],$item['unique_id']);
+ $groups['group'][$item['unique_id']] = $this->_getGroups(
+ $item['groups'],
+ $item['unique_id']
+ );
}
}
$serializedGroups = $this->_helper->serialize($groups);
$subscriber = $this->_subscriberFactory->create();
$subscriber->loadByCustomer($customer->getId());
$interestGroup = $this->interestGroupFactory->create();
- if ($subscriber->getEmail()==$customer->getEmail()) {
- $interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
+ if ($subscriber->getEmail() == $customer->getEmail()) {
+ $interestGroup->getBySubscriberIdStoreId(
+ $subscriber->getSubscriberId(),
+ $subscriber->getStoreId()
+ );
$interestGroup->setGroupdata($serializedGroups);
$interestGroup->setSubscriberId($subscriber->getSubscriberId());
$interestGroup->setStoreId($subscriber->getStoreId());
@@ -297,7 +303,10 @@ protected function _processMerges(\Magento\Customer\Model\Customer $customer, $d
} else {
$this->_subscriberFactory->create()->subscribe($customer->getEmail());
$subscriber->loadBySubscriberEmail($customer->getEmail(), $customer->getStoreId());
- $interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
+ $interestGroup->getBySubscriberIdStoreId(
+ $subscriber->getSubscriberId(),
+ $subscriber->getStoreId()
+ );
$interestGroup->setGroupdata($serializedGroups);
$interestGroup->setSubscriberId($subscriber->getSubscriberId());
$interestGroup->setStoreId($subscriber->getStoreId());
@@ -308,7 +317,10 @@ protected function _processMerges(\Magento\Customer\Model\Customer $customer, $d
if (is_array($mapFields)) {
foreach ($mapFields as $map) {
if ($map['mailchimp'] == $key) {
- if (!$map['isAddress'] && $map['customer_field'] != "dob" && strpos($map['customer_field'], '##') !== false) {
+ if (!$map['isAddress'] && $map['customer_field'] != "dob" && strpos(
+ $map['customer_field'],
+ '##'
+ ) !== false) {
if (count($map['options'])) {
foreach ($map['options'] as $option) {
if ($option['label'] == $value) {
@@ -340,13 +352,14 @@ protected function _subscribeMember(\Magento\Newsletter\Model\Subscriber $subscr
$subscriber->setIsStatusChanged(true);
$subscriber->getResource()->save($subscriber);
}
+
protected function _loadGroups()
{
foreach ($this->storeManager->getStores() as $storeId => $val) {
if (!$this->_helper->isMailChimpEnabled($storeId)) {
continue;
}
- $listId =$this->_helper->getDefaultList($storeId);
+ $listId = $this->_helper->getDefaultList($storeId);
$api = $this->_helper->getApi($storeId);
$interestsCat = $api->lists->interestCategory->getAll($listId, null, null, 200);
if (isset($interestsCat['categories'])) {
@@ -357,18 +370,20 @@ protected function _loadGroups()
}
}
}
+
protected function _getGroups($groups, $cat)
{
$rc = [];
- $gr = explode(",",$groups);
+ $gr = explode(",", $groups);
foreach ($gr as $g) {
foreach ($this->groups as $group) {
- if (trim($g)==$group['name']&&$group['category_id']==$cat) {
+ if (trim($g) == $group['name'] && $group['category_id'] == $cat) {
$rc[$group['id']] = $group['id'];
break;
}
}
}
+
return $rc;
}
}
diff --git a/Cron/WebhookClean.php b/Cron/WebhookClean.php
index a51471c2..acb87f38 100644
--- a/Cron/WebhookClean.php
+++ b/Cron/WebhookClean.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 22/11/18 10:02 AM
- * @file: WebhookClean.php
- */
+
namespace Ebizmarts\MailChimp\Cron;
class WebhookClean
@@ -24,7 +14,6 @@ class WebhookClean
protected $webhooks;
/**
- * WebhookClean constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest $webhookRequest
*/
@@ -32,9 +21,10 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Ebizmarts\MailChimp\Model\MailChimpWebhookRequest $webhookRequest
) {
- $this->helper = $helper;
+ $this->helper = $helper;
$this->webhooks = $webhookRequest;
}
+
public function execute()
{
try {
diff --git a/Helper/Data.php b/Helper/Data.php
index 00c9ebce..3e018387 100755
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -1,90 +1,79 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Helper;
use Magento\Framework\App\ResourceConnection;
-use Magento\Framework\Exception\ValidatorException;
-use Magento\Store\Model\Store;
use Symfony\Component\Config\Definition\Exception\Exception;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
- const XML_PATH_ACTIVE = 'mailchimp/general/active';
- const XML_PATH_APIKEY = 'mailchimp/general/apikey';
- const XML_PATH_APIKEY_LIST = 'mailchimp/general/apikeylist';
- const XML_PATH_MAXLISTAMOUNT = 'mailchimp/general/maxlistamount';
- const XML_PATH_LIST = 'mailchimp/general/monkeylist';
- const XML_PATH_WEBHOOK_ACTIVE = 'mailchimp/general/webhook_active';
- const XML_PATH_WEBHOOK_DELETE = 'mailchimp/general/webhook_delete';
- const XML_PATH_LOG = 'mailchimp/general/log';
- const XML_PATH_TIMEOUT = 'mailchimp/general/timeout';
- const XML_PATH_MAPPING = 'mailchimp/general/mapping';
- const XML_MAILCHIMP_STORE = 'mailchimp/general/monkeystore';
- const XML_MAILCHIMP_JS_URL = 'mailchimp/general/mailchimpjsurl';
+ const XML_PATH_ACTIVE = 'mailchimp/general/active';
+ const XML_PATH_APIKEY = 'mailchimp/general/apikey';
+ const XML_PATH_APIKEY_LIST = 'mailchimp/general/apikeylist';
+ const XML_PATH_MAXLISTAMOUNT = 'mailchimp/general/maxlistamount';
+ const XML_PATH_LIST = 'mailchimp/general/monkeylist';
+ const XML_PATH_WEBHOOK_ACTIVE = 'mailchimp/general/webhook_active';
+ const XML_PATH_WEBHOOK_DELETE = 'mailchimp/general/webhook_delete';
+ const XML_PATH_LOG = 'mailchimp/general/log';
+ const XML_PATH_TIMEOUT = 'mailchimp/general/timeout';
+ const XML_PATH_MAPPING = 'mailchimp/general/mapping';
+ const XML_MAILCHIMP_STORE = 'mailchimp/general/monkeystore';
+ const XML_MAILCHIMP_JS_URL = 'mailchimp/general/mailchimpjsurl';
const XML_PATH_CONFIRMATION_FLAG = 'newsletter/subscription/confirm';
- const XML_PATH_STORE = 'mailchimp/ecommerce/store';
- const XML_PATH_ECOMMERCE_ACTIVE = 'mailchimp/ecommerce/active';
- const XML_PATH_SYNC_DATE = 'mailchimp/general/mcminsyncdateflag';
- const XML_ECOMMERCE_OPTIN = 'mailchimp/ecommerce/customer_optin';
- const XML_ECOMMERCE_FIRSTDATE = 'mailchimp/ecommerce/firstdate';
- const XML_ABANDONEDCART_ACTIVE = 'mailchimp/abandonedcart/active';
- const XML_ABANDONEDCART_FIRSTDATE = 'mailchimp/abandonedcart/firstdate';
- const XML_ABANDONEDCART_PAGE = 'mailchimp/abandonedcart/page';
- const XML_PATH_IS_SYNC = 'mailchimp/general/issync';
- const XML_ABANDONEDCART_EMAIL = 'mailchimp/abandonedcart/save_email_in_quote';
- const XML_MERGEVARS = 'mailchimp/general/map_fields';
- const XML_INTEREST = 'mailchimp/general/interest';
- const XML_INTEREST_IN_SUCCESS = 'mailchimp/general/interest_in_success';
- const XML_INTEREST_SUCCESS_HTML_BEFORE = 'mailchimp/general/interest_success_html_before';
- const XML_INTEREST_SUCCESS_HTML_AFTER = 'mailchimp/general/interest_success_html_after';
- const XML_MAGENTO_MAIL = 'mailchimp/general/magentoemail';
- const XML_SEND_PROMO = 'mailchimp/ecommerce/send_promo';
- const XML_INCLUDING_TAXES = 'mailchimp/ecommerce/including_taxes';
- const XML_POPUP_FORM = 'mailchimp/general/popup_form';
- const XML_POPUP_URL = 'mailchimp/general/popup_url';
- const XML_CLEAN_ERROR_MONTHS = 'mailchimp/ecommerce/clean_errors_months';
-
- const ORDER_STATE_OK = 'complete';
-
- const GUEST_GROUP = 'NOT LOGGED IN';
- const IS_CUSTOMER = "CUS";
- const IS_PRODUCT = "PRO";
- const IS_ORDER = "ORD";
- const IS_QUOTE = "QUO";
+ const XML_PATH_STORE = 'mailchimp/ecommerce/store';
+ const XML_PATH_ECOMMERCE_ACTIVE = 'mailchimp/ecommerce/active';
+ const XML_PATH_SYNC_DATE = 'mailchimp/general/mcminsyncdateflag';
+ const XML_ECOMMERCE_OPTIN = 'mailchimp/ecommerce/customer_optin';
+ const XML_ECOMMERCE_FIRSTDATE = 'mailchimp/ecommerce/firstdate';
+ const XML_ABANDONEDCART_ACTIVE = 'mailchimp/abandonedcart/active';
+ const XML_ABANDONEDCART_FIRSTDATE = 'mailchimp/abandonedcart/firstdate';
+ const XML_ABANDONEDCART_PAGE = 'mailchimp/abandonedcart/page';
+ const XML_PATH_IS_SYNC = 'mailchimp/general/issync';
+ const XML_ABANDONEDCART_EMAIL = 'mailchimp/abandonedcart/save_email_in_quote';
+ const XML_MERGEVARS = 'mailchimp/general/map_fields';
+ const XML_INTEREST = 'mailchimp/general/interest';
+ const XML_INTEREST_IN_SUCCESS = 'mailchimp/general/interest_in_success';
+ const XML_INTEREST_SUCCESS_HTML_BEFORE = 'mailchimp/general/interest_success_html_before';
+ const XML_INTEREST_SUCCESS_HTML_AFTER = 'mailchimp/general/interest_success_html_after';
+ const XML_MAGENTO_MAIL = 'mailchimp/general/magentoemail';
+ const XML_SEND_PROMO = 'mailchimp/ecommerce/send_promo';
+ const XML_INCLUDING_TAXES = 'mailchimp/ecommerce/including_taxes';
+ const XML_POPUP_FORM = 'mailchimp/general/popup_form';
+ const XML_POPUP_URL = 'mailchimp/general/popup_url';
+ const XML_CLEAN_ERROR_MONTHS = 'mailchimp/ecommerce/clean_errors_months';
+
+ const ORDER_STATE_OK = 'complete';
+
+ const GUEST_GROUP = 'NOT LOGGED IN';
+ const IS_CUSTOMER = "CUS";
+ const IS_PRODUCT = "PRO";
+ const IS_ORDER = "ORD";
+ const IS_QUOTE = "QUO";
const IS_SUBSCRIBER = "SUB";
const IS_PROMO_RULE = "PRL";
const IS_PROMO_CODE = "PCD";
- const PLATFORM = 'Magento2';
- const MAXSTORES = 200;
-
- const SUB_MOD = "SubscriberModified";
- const SUB_NEW = "SubscriberNew";
- const PRO_MOD = "ProductModified";
- const PRO_NEW = "ProductNew";
- const CUS_MOD = "CustomerModified";
- const CUS_NEW = "CustomerNew";
- const ORD_MOD = "OrderModified";
- const ORD_NEW = "OrderNew";
- const QUO_MOD = "QuoteModified";
- const QUO_NEW = "QuoteNew";
-
- const SYNCED = 1;
- const NEEDTORESYNC = 2;
- const WAITINGSYNC = 3;
- const SYNCERROR = 4;
+ const PLATFORM = 'Magento2';
+ const MAXSTORES = 200;
+
+ const SUB_MOD = "SubscriberModified";
+ const SUB_NEW = "SubscriberNew";
+ const PRO_MOD = "ProductModified";
+ const PRO_NEW = "ProductNew";
+ const CUS_MOD = "CustomerModified";
+ const CUS_NEW = "CustomerNew";
+ const ORD_MOD = "OrderModified";
+ const ORD_NEW = "OrderNew";
+ const QUO_MOD = "QuoteModified";
+ const QUO_NEW = "QuoteNew";
+
+ const SYNCED = 1;
+ const NEEDTORESYNC = 2;
+ const WAITINGSYNC = 3;
+ const SYNCERROR = 4;
const NOTSYNCED = 5;
- const NEVERSYNC = 0;
+ const NEVERSYNC = 0;
const BATCH_CANCELED = 'canceled';
const BATCH_COMPLETED = 'completed';
@@ -191,9 +180,9 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
* @var \Magento\Framework\Locale\Resolver
*/
protected $resolver;
- private $customerAtt = null;
- private $addressAtt = null;
- private $_mapFields = null;
+ private $customerAtt = null;
+ private $addressAtt = null;
+ private $_mapFields = null;
/**
* @param \Magento\Framework\App\Helper\Context $context
@@ -245,31 +234,30 @@ public function __construct(
\Magento\Directory\Model\CountryFactory $countryFactory,
\Magento\Framework\Locale\Resolver $resolver
) {
-
- $this->_storeManager = $storeManager;
- $this->_mlogger = $logger;
- $this->_scopeConfig = $context->getScopeConfig();
- $this->_request = $context->getRequest();
- $this->_loader = $loader;
- $this->_config = $config;
- $this->_api = $api;
- $this->_syncBatches = $syncBatches;
- $this->_mailChimpStores = $mailChimpStores;
- $this->_mailChimpStoresFactory = $mailChimpStoresFactory;
- $this->_encryptor = $encryptor;
- $this->_subscriberCollection = $subscriberCollection;
- $this->_customerCollection = $customerCollection;
- $this->_resource = $resource;
- $this->_cacheTypeList = $cacheTypeList;
- $this->_attCollection = $attCollection;
- $this->_customerFactory = $customerFactory;
- $this->_countryInformation = $countryInformation;
- $this->_interestGroupFactory = $interestGroupFactory;
- $this->_serializer = $serializer;
- $this->_deploymentConfig = $deploymentConfig;
- $this->_date = $date;
- $this->countryFactory = $countryFactory;
- $this->resolver = $resolver;
+ $this->_storeManager = $storeManager;
+ $this->_mlogger = $logger;
+ $this->_scopeConfig = $context->getScopeConfig();
+ $this->_request = $context->getRequest();
+ $this->_loader = $loader;
+ $this->_config = $config;
+ $this->_api = $api;
+ $this->_syncBatches = $syncBatches;
+ $this->_mailChimpStores = $mailChimpStores;
+ $this->_mailChimpStoresFactory = $mailChimpStoresFactory;
+ $this->_encryptor = $encryptor;
+ $this->_subscriberCollection = $subscriberCollection;
+ $this->_customerCollection = $customerCollection;
+ $this->_resource = $resource;
+ $this->_cacheTypeList = $cacheTypeList;
+ $this->_attCollection = $attCollection;
+ $this->_customerFactory = $customerFactory;
+ $this->_countryInformation = $countryInformation;
+ $this->_interestGroupFactory = $interestGroupFactory;
+ $this->_serializer = $serializer;
+ $this->_deploymentConfig = $deploymentConfig;
+ $this->_date = $date;
+ $this->countryFactory = $countryFactory;
+ $this->resolver = $resolver;
parent::__construct($context);
}
@@ -297,13 +285,16 @@ public function isDoubleOptInEnabled($store = null)
*/
public function getApiKey($store = null, $scope = null)
{
- $apiKey =$this->getConfigValue(self::XML_PATH_APIKEY, $store, $scope);
+ $apiKey = $this->getConfigValue(self::XML_PATH_APIKEY, $store, $scope);
+
return $this->_encryptor->decrypt($apiKey);
}
- public function getTimeOut($store=null, $scope=null)
+
+ public function getTimeOut($store = null, $scope = null)
{
return $this->getConfigValue(self::XML_PATH_TIMEOUT, $store, $scope);
}
+
/**
* @param null $store
* @return \Mailchimp
@@ -311,14 +302,16 @@ public function getTimeOut($store=null, $scope=null)
public function getApi($store = null, $scope = null)
{
$apiKey = $this->getApiKey($store, $scope);
- $timeOut = $this->getTimeOut($store,$scope);
+ $timeOut = $this->getTimeOut($store, $scope);
$this->_api->setApiKey($apiKey);
$this->_api->setUserAgent('Mailchimp4Magento' . (string)$this->getModuleVersion());
if ($timeOut) {
$this->_api->setTimeOut($timeOut);
}
+
return $this->_api;
}
+
private function getBindableAttributes()
{
$systemAtt = $this->getCustomerAtts();
@@ -330,6 +323,7 @@ private function getBindableAttributes()
return $ret;
}
+
private function getCustomerAtts()
{
$ret = [];
@@ -348,22 +342,26 @@ private function getCustomerAtts()
} catch (\Exception $e) {
$options = [];
}
- $isDate = ($item->getBackendModel()==\Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class) ? 1:0;
+ $isDate = ($item->getBackendModel(
+ ) == \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class) ? 1 : 0;
$isAddress = (
- $item->getBackendModel()==\Magento\Customer\Model\Customer\Attribute\Backend\Billing::class ||
- $item->getBackendModel()==\Magento\Customer\Model\Customer\Attribute\Backend\Shipping::class) ? 1:0;
+ $item->getBackendModel() == \Magento\Customer\Model\Customer\Attribute\Backend\Billing::class ||
+ $item->getBackendModel(
+ ) == \Magento\Customer\Model\Customer\Attribute\Backend\Shipping::class) ? 1 : 0;
$ret[$item->getId()] = [
'attCode' => $item->getAttributeCode(),
- 'isDate' =>$isDate,
+ 'isDate' => $isDate,
'isAddress' => $isAddress,
- 'options'=>$options
- ] ;
+ 'options' => $options
+ ];
}
$this->customerAtt = $ret;
}
+
return $this->customerAtt;
}
+
private function getAddressAtt()
{
$ret = [];
@@ -383,12 +381,12 @@ private function getAddressAtt()
'default_billing##company'
];
- foreach($elements as $item) {
+ foreach ($elements as $item) {
$ret[$item] = [
- 'attCode' => $item,
- 'isDate' => false,
+ 'attCode' => $item,
+ 'isDate' => false,
'isAddress' => false,
- 'options' => []
+ 'options' => []
];
}
@@ -397,10 +395,12 @@ private function getAddressAtt()
return $this->addressAtt;
}
+
public function resetMapFields()
{
$this->_mapFields = null;
}
+
public function getMapFields($storeId = null)
{
if (!$this->_mapFields) {
@@ -423,8 +423,10 @@ public function getMapFields($storeId = null)
$this->log($e->getMessage());
}
}
+
return $this->_mapFields;
}
+
public function getDateFormat()
{
return 'm/d/Y';
@@ -444,6 +446,7 @@ public function getApiByApiKey($apiKey, $encrypted = false)
$this->_api->setApiKey($apiKey);
}
$this->_api->setUserAgent('Mailchimp4Magento' . (string)$this->getModuleVersion());
+
return $this->_api;
}
@@ -460,8 +463,10 @@ public function getConfigValue($path, $storeId = null, $scope = null)
} else {
$value = $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORES, $storeId);
}
+
return $value;
}
+
public function deleteConfig($path, $storeId = null, $scope = null)
{
$this->_config->deleteConfig($path, $scope, $storeId);
@@ -476,11 +481,14 @@ public function saveConfigValue($path, $value, $storeId = null, $scope = null)
}
$this->_cacheTypeList->cleanType('config');
}
+
public function getMCMinSyncing($storeId)
{
$ret = $this->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC, $storeId);
+
return !$ret;
}
+
public function getCartUrl($storeId, $cartId, $token)
{
$rc = $this->_storeManager->getStore($storeId)->getUrl(
@@ -492,8 +500,10 @@ public function getCartUrl($storeId, $cartId, $token)
'_secure' => true
]
);
+
return $rc;
}
+
public function getRedemptionUrl($storeId, $couponId, $token)
{
$rc = $this->_storeManager->getStore($storeId)->getUrl(
@@ -505,8 +515,10 @@ public function getRedemptionUrl($storeId, $couponId, $token)
'_secure' => true
]
);
+
return $rc;
}
+
public function getSuccessInterestUrl($storeId)
{
$rc = $this->_storeManager->getStore($storeId)->getUrl(
@@ -516,8 +528,10 @@ public function getSuccessInterestUrl($storeId)
'_secure' => true
]
);
+
return $rc;
}
+
/**
* @param null $store
* @return mixed
@@ -557,8 +571,10 @@ public function getModuleVersion()
if (isset($modules['Ebizmarts_MailChimp'])) {
$v = $modules['Ebizmarts_MailChimp']['setup_version'];
}
+
return $v;
}
+
public function deleteStore($mailchimpStore)
{
try {
@@ -571,6 +587,7 @@ public function deleteStore($mailchimpStore)
$this->log($e->getMessage());
}
}
+
public function markAllBatchesAs($mailchimpStore, $fromStatus, $toStatus)
{
$connection = $this->_syncBatches->getResource()->getConnection();
@@ -596,18 +613,22 @@ public function getMCStoreName($storeId)
{
return $this->_storeManager->getStore($storeId)->getFrontendName();
}
+
public function getBaserUrl($storeId, $type)
{
return $this->_storeManager->getStore($storeId)->getBaseUrl($type, true);
}
+
public function getMCMinSyncDateFlag($storeId = null)
{
$syncDate = $this->getConfigValue(self::XML_PATH_SYNC_DATE, $storeId);
- if ($syncDate=='') {
+ if ($syncDate == '') {
$syncDate = '1900-01-01';
}
+
return $syncDate;
}
+
public function getBaseDir()
{
return BP;
@@ -632,17 +653,16 @@ public function getMergeVars(\Magento\Customer\Model\Customer $customer, $storeI
$fieldName = $parts[1];
$customerAddress = $customer->getPrimaryAddress($attributeCode);
if ($customerAddress !== false) {
- if ($fieldName!='company') {
+ if ($fieldName != 'company') {
$addressData = $this->_getAddressValues($customerAddress);
if (!empty($addressData[$fieldName])) {
$value = $addressData[$fieldName];
}
} else {
- $value = $customerAddress->getCompany();
+ $value = $customerAddress->getCompany();
}
}
- }
- else {
+ } else {
$value = $customer->getData($map['customer_field']);
if (!is_null($value)) {
if ($map['isDate']) {
@@ -673,10 +693,10 @@ public function getMergeVars(\Magento\Customer\Model\Customer $customer, $storeI
}
}
}
+
return (!empty($mergeVars)) ? $mergeVars : null;
}
-
/**
* @param \Magento\Customer\Model\Address\AbstractAddress $value
* @return array
@@ -714,6 +734,7 @@ private function _getAddressValues(\Magento\Customer\Model\Address\AbstractAddre
$addressData['telephone'] = $address->getTelephone();
}
}
+
return $addressData;
}
@@ -738,6 +759,7 @@ public function getMergeVarsBySubscriber(\Magento\Newsletter\Model\Subscriber $s
} catch (\Exception $e) {
$this->log($e->getMessage());
}
+
return $mergeVars;
}
@@ -767,6 +789,7 @@ public function getListForMailChimpStore($mailchimpStoreId, $apiKey)
} catch (\Mailchimp_Error $e) {
$this->log($e->getFriendlyMessage());
}
+
return null;
}
@@ -776,12 +799,12 @@ public function getDateMicrotime()
$msec = $microtime[0];
$msecArray = explode('.', $msec);
$date = date('Y-m-d-H-i-s') . '-' . $msecArray[1];
+
return $date;
}
public function loadStores()
{
-
$mcUserName = [];
$allStores = [];
$connection = $this->_mailChimpStores->getResource()->getConnection();
@@ -789,7 +812,7 @@ public function loadStores()
$connection->truncateTable($tableName);
$keys = $this->getAllApiKeys();
foreach ($keys as $apiKey) {
- if (!$apiKey || $apiKey =='') {
+ if (!$apiKey || $apiKey == '') {
continue;
}
$this->_api->setApiKey(trim($apiKey));
@@ -806,13 +829,13 @@ public function loadStores()
}
foreach ($apiStores['stores'] as $store) {
- if ($store['platform']!=self::PLATFORM||in_array($store['id'],$allStores)) {
+ if ($store['platform'] != self::PLATFORM || in_array($store['id'], $allStores)) {
continue;
}
if (isset($store['connected_site'])) {
$name = $store['name'];
} else {
- $name = $store['name'].' (Warning: not connected)';
+ $name = $store['name'] . ' (Warning: not connected)';
}
$allStores[] = $store['id'];
$mstore = $this->_mailChimpStoresFactory->create();
@@ -853,6 +876,7 @@ public function loadStores()
}
}
}
+
public function saveJsUrl($storeId, $scope = null, $mailChimpStoreId = null)
{
if (!$scope) {
@@ -875,8 +899,8 @@ public function saveJsUrl($storeId, $scope = null, $mailChimpStoreId = null)
$this->log($e->getFriendlyMessage());
}
}
-
}
+
public function getJsUrl($storeId)
{
$url = $this->getConfigValue(self::XML_MAILCHIMP_JS_URL, $storeId);
@@ -898,19 +922,20 @@ public function getJsUrl($storeId)
$this->log($e->getFriendlyMessage());
}
}
+
return $url;
}
public function getWebhooksKey()
{
- $keys =explode("\n", $this->_encryptor->exportKeys());
+ $keys = explode("\n", $this->_encryptor->exportKeys());
$crypt = hash('md5', (string)$keys[0]);
$key = substr($crypt, 0, (strlen($crypt) / 2));
return $key;
}
- public function createWebHook($apikey, $listId, $scope=null, $scopeId=null)
+ public function createWebHook($apikey, $listId, $scope = null, $scopeId = null)
{
$events = [
'subscribe' => true,
@@ -931,15 +956,18 @@ public function createWebHook($apikey, $listId, $scope=null, $scopeId=null)
'_scope' => $scopeId,
'wkey' => $this->getWebhooksKey(),
'_nosid' => true,
- '_secure' => true]);
+ '_secure' => true
+ ]);
// the urlencode of the hookUrl not work
$ret = $api->lists->webhooks->add($listId, $hookUrl, $events, $sources);
} catch (\Mailchimp_Error $e) {
$this->log($e->getFriendlyMessage());
- $ret ['message']= $e->getMessage();
+ $ret ['message'] = $e->getMessage();
}
+
return $ret;
}
+
public function deleteWebHook($apikey, $listId)
{
if (empty($listId)) {
@@ -950,7 +978,8 @@ public function deleteWebHook($apikey, $listId)
$webhooks = $api->lists->webhooks->getAll($listId);
$hookUrl = $this->_getUrl(\Ebizmarts\MailChimp\Controller\WebHook\Index::WEBHOOK__PATH, [
'_nosid' => true,
- '_secure' => true]);
+ '_secure' => true
+ ]);
if (isset($webhooks['webhooks'])) {
foreach ($webhooks['webhooks'] as $wh) {
if ($wh['url'] == $hookUrl) {
@@ -976,11 +1005,13 @@ public function loadListSubscribers($listId, $mail)
if (count($storeIds) > 0) {
$collection = $this->_subscriberCollection->create();
$collection
- ->addFieldToFilter('store_id', ['in'=>$storeIds])
- ->addFieldToFilter('subscriber_email', ['eq'=>$mail]);
+ ->addFieldToFilter('store_id', ['in' => $storeIds])
+ ->addFieldToFilter('subscriber_email', ['eq' => $mail]);
}
+
return $collection;
}
+
public function getMagentoStoreIdsByListId($listId)
{
$storeIds = [];
@@ -992,6 +1023,7 @@ public function getMagentoStoreIdsByListId($listId)
}
}
}
+
return $storeIds;
}
@@ -1011,6 +1043,7 @@ public function loadListCustomers($listId, $email)
->addFieldToFilter('store_id', ['in' => $storeIds])
->addFieldToFilter('email', ['eq' => $email]);
}
+
return $customer;
}
@@ -1022,17 +1055,20 @@ public function loadListCustomers($listId, $email)
public function getTableName($tableName, $conn = ResourceConnection::DEFAULT_CONNECTION)
{
$dbName = $this->_deploymentConfig->get("db/connection/$conn/dbname");
- return $dbName.'.'.$this->_resource->getTableName($tableName, $conn);
+
+ return $dbName . '.' . $this->_resource->getTableName($tableName, $conn);
}
+
public function getWebsiteId($storeId)
{
return $this->_storeManager->getStore($storeId)->getWebsiteId();
}
+
public function getInterest($storeId)
{
$rc = [];
$interest = $this->getConfigValue(self::XML_INTEREST, $storeId);
- if ($interest!='') {
+ if ($interest != '') {
$interest = explode(",", $interest);
} else {
$interest = [];
@@ -1051,21 +1087,29 @@ public function getInterest($storeId)
}
}
foreach ($interest as $interestId) {
- $mailchimpInterest = $api->lists->interestCategory->interests->getAll($listId, $interestId, null, null,200);
+ $mailchimpInterest = $api->lists->interestCategory->interests->getAll(
+ $listId,
+ $interestId,
+ null,
+ null,
+ 200
+ );
foreach ($mailchimpInterest['interests'] as $mi) {
$rc[$mi['category_id']]['category'][$mi['display_order']] =
['id' => $mi['id'], 'name' => $mi['name'], 'checked' => false];
}
}
} else {
- $this->log(__('Error retrieving interest groups for store ').$storeId);
+ $this->log(__('Error retrieving interest groups for store ') . $storeId);
$rc = [];
}
} catch (\Mailchimp_Error $e) {
$this->log($e->getFriendlyMessage());
}
+
return $rc;
}
+
public function getSubscriberInterest($subscriberId, $storeId, $interest = null)
{
if (!$interest) {
@@ -1077,7 +1121,7 @@ public function getSubscriberInterest($subscriberId, $storeId, $interest = null)
$interestGroup = $this->_interestGroupFactory->create();
$interestGroup->getBySubscriberIdStoreId($subscriberId, $storeId);
$serialized = $interestGroup->getGroupdata();
- if ($serialized&&is_array($interest)&&count($interest)) {
+ if ($serialized && is_array($interest) && count($interest)) {
try {
$groups = $this->unserialize($serialized);
if (isset($groups['group'])) {
@@ -1109,16 +1153,20 @@ public function getSubscriberInterest($subscriberId, $storeId, $interest = null)
$this->log($e->getMessage());
}
}
+
return $interest;
}
+
public function getGmtDate($format = null)
{
return $this->_date->gmtDate($format);
}
+
public function getGmtTimeStamp()
{
return $this->_date->gmtTimestamp();
}
+
public function getAllApiKeys()
{
$apiKeys = [];
@@ -1128,8 +1176,10 @@ public function getAllApiKeys()
$apiKeys[] = $apiKey;
}
}
+
return $apiKeys;
}
+
public function modifyCounter($index, $increment = 1)
{
if (array_key_exists($index, $this->counters)) {
@@ -1138,6 +1188,7 @@ public function modifyCounter($index, $increment = 1)
$this->counters[$index] = 1;
}
}
+
public function resetCounters()
{
$this->counters = [
@@ -1153,10 +1204,12 @@ public function resetCounters()
self::QUO_MOD => 0
];
}
+
public function getCounters()
{
return $this->counters;
}
+
public function getTotalNewItemsSent()
{
$totalAmount = 0;
@@ -1170,14 +1223,17 @@ public function getTotalNewItemsSent()
return $totalAmount;
}
+
public function serialize($data)
{
return $this->_serializer->serialize($data);
}
+
public function unserialize($string)
{
return $this->_serializer->unserialize($string);
}
+
public function isEmailSavingEnabled($storeId)
{
return $this->_scopeConfig->isSetFlag(
@@ -1186,10 +1242,12 @@ public function isEmailSavingEnabled($storeId)
$storeId
);
}
+
public function decrypt($value)
{
return $this->_encryptor->decrypt($value);
}
+
public function encrypt($value)
{
return $this->_encryptor->encrypt($value);
diff --git a/Helper/Sync.php b/Helper/Sync.php
index ad84393d..faef2369 100644
--- a/Helper/Sync.php
+++ b/Helper/Sync.php
@@ -2,15 +2,15 @@
namespace Ebizmarts\MailChimp\Helper;
+use Ebizmarts\MailChimp\Model\MailChimpErrors;
+use Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce;
+use Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory;
+use Magento\Catalog\Model\ProductFactory;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Exception\ValidatorException;
use Magento\Sales\Model\OrderFactory;
-use Magento\Catalog\Model\ProductFactory;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory;
-use Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory;
-use Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce;
-use Ebizmarts\MailChimp\Model\MailChimpErrors;
class Sync extends AbstractHelper
{
@@ -65,6 +65,7 @@ public function __construct(
$this->productFactory = $productFactory;
parent::__construct($context);
}
+
public function saveEcommerceData(
$storeId,
$entityId,
@@ -136,33 +137,41 @@ public function saveEcommerceData(
}
}
}
+
public function getChimpSyncEcommerce($storeId, $id, $type)
{
$chimp = $this->chimpSyncEcommerceFactory->create();
+
return $chimp->getByStoreIdType($storeId, $id, $type);
}
+
public function markEcommerceAsDeleted($relatedId, $type, $relatedDeletedId = null)
{
$this->chimpSyncEcommerce->markAllAsDeleted($relatedId, $type, $relatedDeletedId);
}
+
public function ecommerceDeleteAllByIdType($id, $type, $mailchimpStoreId)
{
$this->chimpSyncEcommerce->deleteAllByIdType($id, $type, $mailchimpStoreId);
}
+
public function deleteAllByBatchId($batchId)
{
$this->chimpSyncEcommerce->deleteAllByBatchid($batchId);
}
+
public function markRegisterAsModified($registerId, $type)
{
if (!empty($registerId)) {
$this->chimpSyncEcommerce->markAllAsModified($registerId, $type);
}
}
+
public function markAllAsModifiedByIds($mailchimpStoreId, $ids, $type)
{
$this->chimpSyncEcommerce->markAllAsModifiedByIds($mailchimpStoreId, $ids, $type);
}
+
public function resyncAllSubscribers($mailchimpList)
{
$connection = $this->chimpSyncEcommerce->getResource()->getConnection();
@@ -173,6 +182,7 @@ public function resyncAllSubscribers($mailchimpList)
"type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER . "' and mailchimp_store_id = '$mailchimpList'"
);
}
+
public function resyncProducts($mailchimpList)
{
$connection = $this->chimpSyncEcommerce->getResource()->getConnection();
@@ -190,7 +200,7 @@ public function resetErrors($mailchimpStore, $storeId, $retry)
// clean the errors table
$connection = $this->mailChimpErrors->getResource()->getConnection();
$tableName = $this->mailChimpErrors->getResource()->getMainTable();
- $connection->delete($tableName, "mailchimp_store_id = '".$mailchimpStore."'");
+ $connection->delete($tableName, "mailchimp_store_id = '" . $mailchimpStore . "'");
// clean the syncecommerce table with errors
if ($retry) {
$connection = $this->chimpSyncEcommerce->getResource()->getConnection();
diff --git a/Helper/VarsMap.php b/Helper/VarsMap.php
index 7d533d0b..b442f6fa 100644
--- a/Helper/VarsMap.php
+++ b/Helper/VarsMap.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/30/17 10:35 AM
- * @file: VarsMap.php
- */
namespace Ebizmarts\MailChimp\Helper;
@@ -22,7 +11,6 @@ class VarsMap extends \Magento\Framework\App\Helper\AbstractHelper
protected $mathRandom;
/**
- * VarsMap constructor.
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Math\Random $mathRandom
* @param Data $helper
@@ -32,21 +20,24 @@ public function __construct(
\Magento\Framework\Math\Random $mathRandom,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
- $this->_helper = $helper;
- $this->mathRandom = $mathRandom;
+ $this->_helper = $helper;
+ $this->mathRandom = $mathRandom;
parent::__construct($context);
}
+
public function makeArrayFieldValue($value)
{
$value = $this->unserializeValue($value);
$value = $this->encodeArrayFieldValue($value);
+
return $value;
}
+
public function makeStorableArrayFieldValue($value)
{
$value = is_array($value) ? $this->decodeArrayFieldValue($value) : $value;
$value = $this->serializeValue($value);
+
return $value;
}
@@ -68,8 +59,10 @@ protected function isEncodedArrayFieldValue($value)
return false;
}
}
+
return true;
}
+
protected function decodeArrayFieldValue(array $value)
{
$result = [];
@@ -85,8 +78,10 @@ protected function decodeArrayFieldValue(array $value)
$mailchimp_field_id = $row['mailchimp_field_id'];
$result[$customer_field_id] = $mailchimp_field_id;
}
+
return $result;
}
+
protected function serializeValue($value)
{
$rc = '';
@@ -103,8 +98,10 @@ protected function serializeValue($value)
$this->_helper->log($e->getMessage());
}
}
+
return $rc;
}
+
protected function unserializeValue($value)
{
$rc = [];
@@ -115,15 +112,18 @@ protected function unserializeValue($value)
$this->_helper->log($e->getMessage());
}
}
+
return $rc;
}
+
protected function encodeArrayFieldValue(array $value)
{
$result = [];
foreach ($value as $customerFieldId => $mailchimpName) {
$resultId = $this->mathRandom->getUniqueHash('_');
- $result[$resultId] = ['mailchimp_field_id' => $mailchimpName ,'customer_field_id' => $customerFieldId];
+ $result[$resultId] = ['mailchimp_field_id' => $mailchimpName, 'customer_field_id' => $customerFieldId];
}
+
return $result;
}
}
diff --git a/Model/Api/Cart.php b/Model/Api/Cart.php
index eabe664c..feb88451 100644
--- a/Model/Api/Cart.php
+++ b/Model/Api/Cart.php
@@ -1,18 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/7/17 12:42 PM
- * @file: Cart.php
- */
+
namespace Ebizmarts\MailChimp\Model\Api;
-use Symfony\Component\Config\Definition\Exception\Exception;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class Cart
@@ -85,23 +74,22 @@ public function __construct(
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
\Magento\Framework\Url $urlHelper
) {
-
- $this->_helper = $helper;
- $this->_quoteCollection = $quoteColletcion;
- $this->_customerFactory = $customerFactory;
- $this->_apiProduct = $apiProduct;
- $this->_apiCustomer = $apiCustomer;
- $this->_orderCollectionFactory = $orderCollectionFactory;
- $this->_countryFactory = $countryFactory;
- $this->_urlHelper = $urlHelper;
- $this->syncHelper = $syncHelper;
+ $this->_helper = $helper;
+ $this->_quoteCollection = $quoteColletcion;
+ $this->_customerFactory = $customerFactory;
+ $this->_apiProduct = $apiProduct;
+ $this->_apiCustomer = $apiCustomer;
+ $this->_orderCollectionFactory = $orderCollectionFactory;
+ $this->_countryFactory = $countryFactory;
+ $this->_urlHelper = $urlHelper;
+ $this->syncHelper = $syncHelper;
}
- /**
- * @param $mailchimpStoreId
- * @param $magentoStoreId
- * @return array
- */
+ /**
+ * @param $mailchimpStoreId
+ * @param $magentoStoreId
+ * @return array
+ */
public function createBatchJson($magentoStoreId)
{
$allCarts = [];
@@ -131,13 +119,14 @@ public function createBatchJson($magentoStoreId)
$this->_counter = 0;
$date = $this->_helper->getDateMicrotime();
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE.'_'.$date;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE . '_' . $date;
// get all the carts converted in orders (must be deleted on mailchimp)
$allCarts = array_merge($allCarts, $this->_getConvertedQuotes($mailchimpStoreId, $magentoStoreId));
// get all the carts modified but not converted in orders
$allCarts = array_merge($allCarts, $this->_getModifiedQuotes($mailchimpStoreId, $magentoStoreId));
// get new carts
$allCarts = array_merge($allCarts, $this->_getNewQuotes($mailchimpStoreId, $magentoStoreId));
+
return $allCarts;
}
@@ -153,11 +142,13 @@ protected function _getConvertedQuotes($mailchimpStoreId, $magentoStoreId)
// get only the converted quotes
$convertedCarts->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
$convertedCarts->addFieldToFilter('is_active', ['eq' => 0]);
- $convertedCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id','customer_email']);
+ $convertedCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(
+ ['entity_id', 'customer_email']
+ );
//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$convertedCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_QUOTE."'
+ "m4m.related_id = main_table.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE . "'
AND m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
@@ -228,20 +219,29 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
$allCarts = [];
$modifiedCarts = $this->_getQuoteCollection();
// select carts with no orders
- $modifiedCarts->addFieldToFilter('is_active', ['eq'=>1]);
+ $modifiedCarts->addFieldToFilter('is_active', ['eq' => 1]);
// select carts for the current Magento store id
$modifiedCarts->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
- $modifiedCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id','customer_id','customer_email','mailchimp_campaign_id','quote_currency_code','grand_total']);
+ $modifiedCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(
+ [
+ 'entity_id',
+ 'customer_id',
+ 'customer_email',
+ 'mailchimp_campaign_id',
+ 'quote_currency_code',
+ 'grand_total'
+ ]
+ );
//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$modifiedCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_QUOTE."'
+ "m4m.related_id = main_table.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE . "'
AND m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
// be sure that the quotes are already in mailchimp and not deleted
$modifiedCarts->getSelect()->where(
- "(m4m.mailchimp_sync_deleted is null or m4m.mailchimp_sync_deleted = 0)".
+ "(m4m.mailchimp_sync_deleted is null or m4m.mailchimp_sync_deleted = 0)" .
" AND m4m.mailchimp_sync_modified = 1"
);
// limit the collection
@@ -292,7 +292,7 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
$allCartsForEmail->clear();
}
// avoid carts abandoned as guests when customer email associated to a registered customer.
- if (!$cart->getCustomerId() && $customer->getEmail()==$cart->getCustomerEmail()) {
+ if (!$cart->getCustomerId() && $customer->getEmail() == $cart->getCustomerEmail()) {
$this->_updateQuote($mailchimpStoreId, $cartId);
continue;
}
@@ -315,7 +315,7 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
if (count($cart->getAllVisibleItems())) {
$cartJson = $this->_makeCart($cart, $mailchimpStoreId, $magentoStoreId);
- if ($cartJson!==false) {
+ if ($cartJson !== false) {
if (!empty($cartJson)) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::QUO_MOD);
$allCarts[$this->_counter]['method'] = 'PATCH';
@@ -345,6 +345,7 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
}
}
}
+
return $allCarts;
}
@@ -356,16 +357,26 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
{
$allCarts = [];
$newCarts = $this->_getQuoteCollection();
- $newCarts->addFieldToFilter('is_active', ['eq'=>1]);
- $newCarts->addFieldToFilter('customer_email', ['notnull'=>true]);
- $newCarts->addFieldToFilter('items_count', ['gt'=>0]);
+ $newCarts->addFieldToFilter('is_active', ['eq' => 1]);
+ $newCarts->addFieldToFilter('customer_email', ['notnull' => true]);
+ $newCarts->addFieldToFilter('items_count', ['gt' => 0]);
// select carts for the current Magento store id
$newCarts->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
// filter by first date if exists.
if ($this->_firstDate) {
$newCarts->addFieldToFilter('created_at', ['gt' => $this->_firstDate]);
}
- $newCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id', 'customer_id','customer_email','mailchimp_campaign_id','updated_at','quote_currency_code','grand_total']);
+ $newCarts->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(
+ [
+ 'entity_id',
+ 'customer_id',
+ 'customer_email',
+ 'mailchimp_campaign_id',
+ 'updated_at',
+ 'quote_currency_code',
+ 'grand_total'
+ ]
+ );
//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$newCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
@@ -424,7 +435,7 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
}
// don't send the carts for guest customers who are registered
- if (!$cart->getCustomerId() && $customer->getEmail()==$cart->getCustomerEmail()) {
+ if (!$cart->getCustomerId() && $customer->getEmail() == $cart->getCustomerEmail()) {
$this->_updateQuote(
$mailchimpStoreId,
$cartId,
@@ -451,7 +462,7 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
}
$cartJson = $this->_makeCart($cart, $mailchimpStoreId, $magentoStoreId);
- if ($cartJson!==false) {
+ if ($cartJson !== false) {
if (!empty($cartJson)) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::QUO_NEW);
$allCarts[$this->_counter]['method'] = 'POST';
@@ -485,7 +496,6 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
/**
* Get all existing carts in the current store view for a given email address.
- *
* @param $email
* @param $mailchimpStoreId
* @param $magentoStoreId
@@ -499,12 +509,13 @@ protected function _getAllCartsByEmail($email, $mailchimpStoreId, $magentoStoreI
$allCartsForEmail->addFieldToFilter('customer_email', ['eq' => $email]);
$allCartsForEmail->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_QUOTE."'
+ "m4m.related_id = main_table.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE . "'
AND m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
// be sure that the quotes are already in mailchimp and not deleted
$allCartsForEmail->getSelect()->where("m4m.mailchimp_sync_deleted = 0");
+
return $allCartsForEmail;
}
@@ -537,11 +548,11 @@ protected function _makeCart(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId
*/
foreach ($items as $item) {
$line = [];
- if ($item->getProductType()=='bundle' || $item->getProductType()=='grouped') {
+ if ($item->getProductType() == 'bundle' || $item->getProductType() == 'grouped') {
continue;
}
- if ($item->getProductType()==\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
+ if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
$variant = null;
if ($item->getOptionByCode('simple_product')) {
$variant = $item->getOptionByCode('simple_product')->getProduct();
@@ -574,11 +585,13 @@ protected function _makeCart(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId
if ($jsonData === false) {
$jsonErrormsg = json_last_error_msg();
$this->_helper->log("");
- $this->_helper->log("$jsonErrormsg on cart [".$cart->getId()."]");
+ $this->_helper->log("$jsonErrormsg on cart [" . $cart->getId() . "]");
}
}
+
return $jsonData;
}
+
/**
* @param \Magento\Quote\Model\Quote $cart
* @return string
@@ -589,8 +602,10 @@ protected function _getCheckoutUrl(\Magento\Quote\Model\Quote $cart, $storeId)
$this->_token = hash('md5', rand(0, 9999999));
}
$url = $this->_helper->getCartUrl($storeId, $cart->getId(), $this->_token);
+
return $url;
}
+
protected function _getCustomer(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId, $magentoStoreId)
{
$customer = [
@@ -650,6 +665,7 @@ protected function _getCustomer(\Magento\Quote\Model\Quote $cart, $mailchimpStor
$customer['address'] = $address;
}
}
+
return $customer;
}
diff --git a/Model/Api/Customer.php b/Model/Api/Customer.php
index e0900981..92dec9d6 100644
--- a/Model/Api/Customer.php
+++ b/Model/Api/Customer.php
@@ -1,26 +1,13 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/1/16 12:00 PM
- * @file: Customer.php
- */
namespace Ebizmarts\MailChimp\Model\Api;
-use Magento\Directory\Model\CountryFactory;
-use Magento\Framework\Exception\State\ExpiredException;
-use Symfony\Component\Config\Definition\Exception\Exception;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\Directory\Model\CountryFactory;
class Customer
{
- const MAX = 100;
+ const MAX = 100;
/**
* @var \Ebizmarts\MailChimp\Helper\Data
*/
@@ -79,18 +66,18 @@ public function __construct(
\Magento\Customer\Model\Address $address,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
) {
-
- $this->_helper = $helper;
- $this->_collection = $collection;
- $this->_orderCollection = $orderCollection;
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER. '_' .
+ $this->_helper = $helper;
+ $this->_collection = $collection;
+ $this->_orderCollection = $orderCollection;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER . '_' .
$this->_helper->getGmtTimeStamp();
- $this->_address = $address;
- $this->_customerFactory = $customerFactory;
- $this->_countryFactory = $countryFactory;
- $this->subscriberFactory = $subscriberFactory;
- $this->syncHelper = $syncHelper;
+ $this->_address = $address;
+ $this->_customerFactory = $customerFactory;
+ $this->_countryFactory = $countryFactory;
+ $this->subscriberFactory = $subscriberFactory;
+ $this->syncHelper = $syncHelper;
}
+
public function sendCustomers($storeId)
{
$mailchimpStoreId = $this->_helper->getConfigValue(
@@ -99,17 +86,19 @@ public function sendCustomers($storeId)
);
$listId = $this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST, $storeId);
$collection = $this->_collection->create();
- $collection->addFieldToFilter('store_id', ['eq'=>$storeId]);
- $collection->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id','store_id']);
+ $collection->addFieldToFilter('store_id', ['eq' => $storeId]);
+ $collection->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id', 'store_id']);
$collection->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = e.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER.
- "' and m4m.mailchimp_store_id = '".$mailchimpStoreId."'",
+ "m4m.related_id = e.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER .
+ "' and m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
- $collection->getSelect()->where("m4m.mailchimp_sync_delta IS null ".
- "OR (m4m.mailchimp_sync_delta > '".$this->_helper->getMCMinSyncDateFlag().
- "' and m4m.mailchimp_sync_modified = 1)");
+ $collection->getSelect()->where(
+ "m4m.mailchimp_sync_delta IS null " .
+ "OR (m4m.mailchimp_sync_delta > '" . $this->_helper->getMCMinSyncDateFlag() .
+ "' and m4m.mailchimp_sync_modified = 1)"
+ );
$collection->getSelect()->limit(self::MAX);
$counter = 0;
$customerArray = [];
@@ -118,11 +107,11 @@ public function sendCustomers($storeId)
foreach ($collection as $item) {
$customer = $this->_customerFactory->create();
$customer->getResource()->load($customer, $item->getId());
- $data = $this->_buildCustomerData($customer);
- $customerJson = '';
+ $data = $this->_buildCustomerData($customer);
+ $customerJson = '';
$customerJson = json_encode($data);
- if ($customerJson!==false) {
+ if ($customerJson !== false) {
if (!empty($customerJson)) {
if ($item->getMailchimpSyncModified() == 1) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::CUS_MOD);
@@ -139,12 +128,12 @@ public function sendCustomers($storeId)
if (!$this->isSubscriber($customer)) {
$subscriberData = $this->buildSubscriberData($customer);
$subscriberJson = json_encode($subscriberData);
- if ($subscriberJson !==false) {
+ if ($subscriberJson !== false) {
$customerArray[$counter]['method'] = "PATCH";
$customerArray[$counter]['path'] = "/lists/" . $listId . "/members/" .
$customerMailchimpId;
$customerArray[$counter]['operation_id'] = $this->_batchId . '_' .
- $customer->getId().'_SUB';
+ $customer->getId() . '_SUB';
$customerArray[$counter]['body'] = $subscriberJson;
$counter++;
}
@@ -170,8 +159,10 @@ public function sendCustomers($storeId)
);
}
}
+
return $customerArray;
}
+
/**
* @param \Magento\Customer\Model\Customer $customer
* @return mixed
@@ -180,8 +171,10 @@ protected function buildSubscriberData(\Magento\Customer\Model\Customer $custome
{
$data = [];
$data["merge_fields"] = $this->_helper->getMergeVars($customer, $customer->getData('store_id'));
+
return $data;
}
+
protected function isSubscriber(\Magento\Customer\Model\Customer $customer)
{
$subscriber = $this->subscriberFactory->create();
@@ -191,6 +184,7 @@ protected function isSubscriber(\Magento\Customer\Model\Customer $customer)
return true;
}
}
+
return false;
}
@@ -210,8 +204,9 @@ protected function _buildCustomerData(\Magento\Customer\Model\Customer $customer
// customer order data
$orderCollection = $this->_orderCollection->create();
$orderCollection->addFieldToFilter('state', [
- ['neq',\Magento\Sales\Model\Order::STATE_CANCELED],
- ['neq',\Magento\Sales\Model\Order::STATE_CLOSED]])
+ ['neq', \Magento\Sales\Model\Order::STATE_CANCELED],
+ ['neq', \Magento\Sales\Model\Order::STATE_CLOSED]
+ ])
->addAttributeToFilter('customer_id', ['eq' => $customer->getId()]);
$totalOrders = 0;
$totalAmountSpent = 0;
@@ -223,8 +218,8 @@ protected function _buildCustomerData(\Magento\Customer\Model\Customer $customer
$totalAmountSpent += $customerOrder->getGrandTotal() - $customerOrder->getTotalRefunded()
- $customerOrder->getTotalCanceled();
}
- $data['orders_count'] = $totalOrders;
- $data['total_spent'] = $totalAmountSpent;
+ $data['orders_count'] = $totalOrders;
+ $data['total_spent'] = $totalAmountSpent;
$address = $customer->getDefaultBillingAddress();
if ($address) {
$customerAddress = [];
@@ -261,6 +256,7 @@ protected function _buildCustomerData(\Magento\Customer\Model\Customer $customer
$data["address"] = $customerAddress;
}
}
+
return $data;
}
@@ -271,8 +267,10 @@ public function getOptin($storeId = 0)
} else {
$optin = false;
}
+
return $optin;
}
+
protected function _updateCustomer(
$storeId,
$entityId,
diff --git a/Model/Api/Order.php b/Model/Api/Order.php
index 31c20603..dacc0ade 100644
--- a/Model/Api/Order.php
+++ b/Model/Api/Order.php
@@ -1,20 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/21/16 3:51 PM
- * @file: Order.php
- */
namespace Ebizmarts\MailChimp\Model\Api;
-use Magento\SalesRule\Model\RuleRepository;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\SalesRule\Model\RuleRepository;
use Symfony\Component\Config\Definition\Exception\Exception;
class Order
@@ -116,27 +105,25 @@ public function __construct(
\Magento\SalesRule\Model\RuleRepository $ruleRepository,
\Magento\Framework\Url $urlHelper
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_order = $order;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_order = $order;
$this->_orderCollectionFactory = $orderCollectionFactory;
- $this->_apiProduct = $apiProduct;
- $this->_productFactory = $productFactory;
- $this->_product = $product;
- $this->_apiCustomer = $apiCustomer;
- $this->_countryFactory = $countryFactory;
- $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_ORDER. '_' . $this->_helper->getGmtTimeStamp();
+ $this->_apiProduct = $apiProduct;
+ $this->_productFactory = $productFactory;
+ $this->_product = $product;
+ $this->_apiCustomer = $apiCustomer;
+ $this->_countryFactory = $countryFactory;
+ $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_ORDER . '_' . $this->_helper->getGmtTimeStamp();
$this->_counter = 0;
- $this->_urlHelper = $urlHelper;
+ $this->_urlHelper = $urlHelper;
$this->couponRepository = $couponRepository;
$this->ruleRepository = $ruleRepository;
}
/**
* Set the request for orders to be created on MailChimp
- *
* @param $mailchimpStoreId
* @param $magentoStoreId
* @return array
@@ -144,18 +131,24 @@ public function __construct(
public function sendOrders($magentoStoreId)
{
$batchArray = [];
- $this->_firstDate = $this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_ECOMMERCE_FIRSTDATE, $magentoStoreId);
+ $this->_firstDate = $this->_helper->getConfigValue(
+ \Ebizmarts\MailChimp\Helper\Data::XML_ECOMMERCE_FIRSTDATE,
+ $magentoStoreId
+ );
// get all the orders modified
$batchArray = array_merge($batchArray, $this->_getModifiedOrders($magentoStoreId));
// get new orders
$batchArray = array_merge($batchArray, $this->_getNewOrders($magentoStoreId));
+
return $batchArray;
}
+
protected function _getCollection()
{
return $this->_orderCollectionFactory->create();
}
+
protected function _getModifiedOrders($magentoStoreId)
{
$batchArray = [];
@@ -166,17 +159,17 @@ protected function _getModifiedOrders($magentoStoreId)
$modifiedOrders = $this->_getCollection();
// select orders for the current Magento store id
$modifiedOrders->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
- $modifiedOrders->addFieldToSelect(['store_id','created_at']);
+ $modifiedOrders->addFieldToSelect(['store_id', 'created_at']);
//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$modifiedOrders->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_ORDER.
- "' and m4m.mailchimp_store_id = '".$mailchimpStoreId."'",
+ "m4m.related_id = main_table.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_ORDER .
+ "' and m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
// be sure that the order are already in mailchimp and not deleted
$modifiedOrders->getSelect()->where(
- "m4m.mailchimp_sync_modified = 1 AND m4m.mailchimp_store_id = '".$mailchimpStoreId."'"
+ "m4m.mailchimp_sync_modified = 1 AND m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'"
);
// limit the collection
$modifiedOrders->getSelect()->limit(self::BATCH_LIMIT);
@@ -205,7 +198,7 @@ protected function _getModifiedOrders($magentoStoreId)
}
$orderJson = $this->generatePOSTPayload($order, $mailchimpStoreId, $magentoStoreId, true);
- if ($orderJson!==false) {
+ if ($orderJson !== false) {
if (!empty($orderJson)) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::ORD_MOD);
$batchArray[$this->_counter]['method'] = "PATCH";
@@ -214,7 +207,7 @@ protected function _getModifiedOrders($magentoStoreId)
$batchArray[$this->_counter]['operation_id'] = $this->_batchId . '_' . $orderId;
$batchArray[$this->_counter]['body'] = $orderJson;
} else {
- $error = __('Order ['.$order->getIncrementId().'] is empty');
+ $error = __('Order [' . $order->getIncrementId() . '] is empty');
$this->_helper->log($error);
$this->_updateOrder($mailchimpStoreId, $orderId, $this->_helper->getGmtDate(), $error, 0);
continue;
@@ -233,6 +226,7 @@ protected function _getModifiedOrders($magentoStoreId)
$this->_updateOrder($mailchimpStoreId, $orderId, $this->_helper->getGmtDate(), $error, 0);
}
}
+
return $batchArray;
}
@@ -246,15 +240,15 @@ protected function _getNewOrders($magentoStoreId)
$newOrders = $this->_getCollection();
// select carts for the current Magento store id
$newOrders->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
- $newOrders->addFieldToSelect(['store_id','created_at']);
+ $newOrders->addFieldToSelect(['store_id', 'created_at']);
// filter by first date if exists.
if ($this->_firstDate) {
$newOrders->addFieldToFilter('created_at', ['gt' => $this->_firstDate]);
}
$newOrders->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_ORDER.
- "' and m4m.mailchimp_store_id = '".$mailchimpStoreId."'",
+ "m4m.related_id = main_table.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_ORDER .
+ "' and m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
// be sure that the quote are not in mailchimp
@@ -286,7 +280,7 @@ protected function _getNewOrders($magentoStoreId)
}
}
$orderJson = $this->generatePOSTPayload($order, $mailchimpStoreId, $magentoStoreId);
- if ($orderJson!==false) {
+ if ($orderJson !== false) {
if (!empty($orderJson)) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::ORD_NEW);
$batchArray[$this->_counter]['method'] = "POST";
@@ -297,7 +291,7 @@ protected function _getNewOrders($magentoStoreId)
$this->_updateOrder($mailchimpStoreId, $orderId);
$this->_counter++;
} else {
- $error = __('Order ['.$item->getIncrementId().'] is empty');
+ $error = __('Order [' . $item->getIncrementId() . '] is empty');
$this->_helper->log($error);
$this->_updateOrder($mailchimpStoreId, $orderId, $this->_helper->getGmtDate(), $error, 0);
}
@@ -312,12 +306,12 @@ protected function _getNewOrders($magentoStoreId)
$this->_updateOrder($mailchimpStoreId, $orderId, $this->_helper->getGmtDate(), $error, 0);
}
}
+
return $batchArray;
}
/**
* Set all the data for each order to be sent
- *
* @param $order
* @param $mailchimpStoreId
* @param $magentoStoreId
@@ -418,17 +412,18 @@ protected function generatePOSTPayload(
$item->getProductId(),
\Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT
);
- } catch (\Exception $e){
+ } catch (\Exception $e) {
$this->_helper->log($e->getMessage());
continue;
}
- if ($productSyncData->getRelatedId()!=$item->getProductId()||($productSyncData->getRelatedId()==$item->getProductId()&&$productSyncData->getMailchimpSyncDeleted()==1)) {
+ if ($productSyncData->getRelatedId() != $item->getProductId() || ($productSyncData->getRelatedId(
+ ) == $item->getProductId() && $productSyncData->getMailchimpSyncDeleted() == 1)) {
continue;
}
if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
$options = $item->getProductOptions();
if (!isset($options['simple_sku'])) {
- $this->_helper->log('The product ['.$item->getId().'] has no simple_sku');
+ $this->_helper->log('The product [' . $item->getId() . '] has no simple_sku');
continue;
}
$sku = $options['simple_sku'];
@@ -454,6 +449,7 @@ protected function generatePOSTPayload(
}
if (!$itemCount) {
unset($data['lines']);
+
return "";
}
@@ -554,7 +550,8 @@ protected function generatePOSTPayload(
$data["billing_address"]["company"] = $billingAddress->getCompany();
}
} else {
- $this->_helper->log("Order [".$order->getId()."] as no billing address");
+ $this->_helper->log("Order [" . $order->getId() . "] as no billing address");
+
return "";
}
$shippingAddress = $order->getShippingAddress();
@@ -571,7 +568,7 @@ protected function generatePOSTPayload(
$data['shipping_address']["address2"] = $street[1];
}
if (array_key_exists(2, $street)) {
- if (array_key_exists('address2',$data['shipping_address'])) {
+ if (array_key_exists('address2', $data['shipping_address'])) {
$data['shipping_address']["address2"] = $data['shipping_address']["address2"] . ", " . $street[2];
} else {
$data['shipping_address']["address2"] = $street[2];
@@ -609,7 +606,8 @@ protected function generatePOSTPayload(
$orderCollection = $this->_orderCollectionFactory->create();
$orderCollection->addFieldToFilter('state', [
['neq' => \Magento\Sales\Model\Order::STATE_CANCELED],
- ['neq' => \Magento\Sales\Model\Order::STATE_CLOSED]])
+ ['neq' => \Magento\Sales\Model\Order::STATE_CLOSED]
+ ])
->addAttributeToFilter('customer_email', ['eq' => $order->getCustomerEmail()]);
$orderCollection
@@ -634,11 +632,11 @@ protected function generatePOSTPayload(
//enconde to JSON
$jsonData = json_encode($data);
- if ($jsonData===false) {
+ if ($jsonData === false) {
$jsonError = json_last_error();
$jsonErrorMsg = json_last_error_msg();
$this->_helper->log('');
- $this->_helper->log("$jsonErrorMsg on order [".$order->getEntityId()."]");
+ $this->_helper->log("$jsonErrorMsg on order [" . $order->getEntityId() . "]");
}
return $jsonData;
@@ -725,17 +723,20 @@ protected function _getPromoData(\Magento\Sales\Model\Order $order)
$type = 'fixed';
}
- $promo = [[
- 'code' => $couponCode,
- 'amount_discounted' => abs($amountDiscounted),
- 'type' => $type
- ]];
+ $promo = [
+ [
+ 'code' => $couponCode,
+ 'amount_discounted' => abs($amountDiscounted),
+ 'type' => $type
+ ]
+ ];
}
}
}
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->_helper->log($e->getMessage());
}
+
return $promo;
}
diff --git a/Model/Api/Product.php b/Model/Api/Product.php
index 9747d038..aa15712e 100644
--- a/Model/Api/Product.php
+++ b/Model/Api/Product.php
@@ -1,14 +1,4 @@
_productRepository = $productRepository;
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_productCollection = $productCollection;
- $this->_imageHelper = $imageHelper;
- $this->_stockRegistry = $stockRegistry;
- $this->_categoryRepository = $categoryRepository;
- $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
- $this->_configurable = $configurable;
- $this->_option = $option;
- $this->_categoryCollection = $categoryCollection;
- $this->taxHelper = $taxHelper;
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT. '_' .
+ $this->_productRepository = $productRepository;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_productCollection = $productCollection;
+ $this->_imageHelper = $imageHelper;
+ $this->_stockRegistry = $stockRegistry;
+ $this->_categoryRepository = $categoryRepository;
+ $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
+ $this->_configurable = $configurable;
+ $this->_option = $option;
+ $this->_categoryCollection = $categoryCollection;
+ $this->taxHelper = $taxHelper;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT . '_' .
$this->_helper->getGmtTimeStamp();
}
+
public function _sendProducts($magentoStoreId)
{
$batchArray = [];
@@ -134,18 +124,23 @@ public function _sendProducts($magentoStoreId)
);
$this->_markSpecialPrices($magentoStoreId, $mailchimpStoreId);
$collection = $this->_getCollection();
- $collection->addFieldToFilter("type_id", ["nin"=>[\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, "grouped"]]);
+ $collection->addFieldToFilter(
+ "type_id",
+ ["nin" => [\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, "grouped"]]
+ );
$collection->addStoreFilter($magentoStoreId);
$collection->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS)->columns(['entity_id']);
$collection->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = e.entity_id and m4m.type = '".\Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT.
- "' and m4m.mailchimp_store_id = '".$mailchimpStoreId."'",
+ "m4m.related_id = e.entity_id and m4m.type = '" . \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT .
+ "' and m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
- $collection->getSelect()->where("m4m.mailchimp_sync_delta IS null OR (m4m.mailchimp_sync_delta > '".
- $this->_helper->getMCMinSyncDateFlag().
- "' and m4m.mailchimp_sync_modified = 1)");
+ $collection->getSelect()->where(
+ "m4m.mailchimp_sync_delta IS null OR (m4m.mailchimp_sync_delta > '" .
+ $this->_helper->getMCMinSyncDateFlag() .
+ "' and m4m.mailchimp_sync_modified = 1)"
+ );
$collection->getSelect()->limit(self::MAX);
foreach ($collection as $item) {
/**
@@ -154,12 +149,15 @@ public function _sendProducts($magentoStoreId)
$product = $this->_productRepository->getById($item->getId(), false, $magentoStoreId);
if ($item->getMailchimpSyncModified() && $item->getMailchimpSyncDelta() &&
$item->getMailchimpSyncDelta() > $this->_helper->getMCMinSyncDateFlag()) {
- $batchArray = array_merge($this->_buildOldProductRequest(
- $product,
- $this->_batchId,
- $mailchimpStoreId,
- $magentoStoreId
- ), $batchArray);
+ $batchArray = array_merge(
+ $this->_buildOldProductRequest(
+ $product,
+ $this->_batchId,
+ $mailchimpStoreId,
+ $magentoStoreId
+ ),
+ $batchArray
+ );
$this->_updateProduct($mailchimpStoreId, $product->getId());
continue;
} else {
@@ -179,8 +177,10 @@ public function _sendProducts($magentoStoreId)
);
}
}
+
return $batchArray;
}
+
protected function _markSpecialPrices($magentoStoreId, $mailchimpStoreId)
{
/**
@@ -190,27 +190,43 @@ protected function _markSpecialPrices($magentoStoreId, $mailchimpStoreId)
$collection->addStoreFilter($magentoStoreId);
$collection->addAttributeToFilter(
'special_price',
- ['gt'=>0],
+ ['gt' => 0],
'left'
)->addAttributeToFilter(
'special_from_date',
- ['or' => [ 0 => ['date' => true,
- 'to' => date('Y-m-d', time()).' 23:59:59'],
- 1 => ['is' => new \Zend_Db_Expr(
- 'null'
- )],]],
+ [
+ 'or' => [
+ 0 => [
+ 'date' => true,
+ 'to' => date('Y-m-d', time()) . ' 23:59:59'
+ ],
+ 1 => [
+ 'is' => new \Zend_Db_Expr(
+ 'null'
+ )
+ ],
+ ]
+ ],
'left'
)->addAttributeToFilter(
'special_to_date',
- ['or' => [ 0 => ['date' => true,
- 'from' => date('Y-m-d', time()).' 00:00:00'],
- 1 => ['is' => new \Zend_Db_Expr(
- 'null'
- )],]],
+ [
+ 'or' => [
+ 0 => [
+ 'date' => true,
+ 'from' => date('Y-m-d', time()) . ' 00:00:00'
+ ],
+ 1 => [
+ 'is' => new \Zend_Db_Expr(
+ 'null'
+ )
+ ],
+ ]
+ ],
'left'
);
foreach ($collection as $item) {
- $productId = $this->_productRepository->get($item->getSku(),false, $magentoStoreId)->getId();
+ $productId = $this->_productRepository->get($item->getSku(), false, $magentoStoreId)->getId();
$mailchimpSync = $this->syncHelper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO');
if ($mailchimpSync->getMailchimpSyncDelta() < $item->getSpecialFromDate()) {
$this->_updateProduct($mailchimpStoreId, $productId, null, null, 1);
@@ -223,23 +239,29 @@ protected function _markSpecialPrices($magentoStoreId, $mailchimpStoreId)
$collection2->addStoreFilter($magentoStoreId);
$collection2->addAttributeToFilter(
'special_price',
- ['gt'=>0],
+ ['gt' => 0],
'left'
)->addAttributeToFilter(
'special_to_date',
- ['or' => [ 0 => ['date' => true,
- 'to' => date('Y-m-d', time()).' 00:00:00'],
- ]],
+ [
+ 'or' => [
+ 0 => [
+ 'date' => true,
+ 'to' => date('Y-m-d', time()) . ' 00:00:00'
+ ],
+ ]
+ ],
'left'
);
foreach ($collection2 as $item) {
- $productId = $this->_productRepository->get($item->getSku(),false, $magentoStoreId)->getId();
+ $productId = $this->_productRepository->get($item->getSku(), false, $magentoStoreId)->getId();
$mailchimpSync = $this->syncHelper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO');
if ($mailchimpSync->getMailchimpSyncDelta() < $item->getSpecialToDate()) {
$this->_updateProduct($mailchimpStoreId, $productId, null, null, 1);
}
}
}
+
/**
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
*/
@@ -247,12 +269,12 @@ protected function _getCollection()
{
return $this->_productCollection->create();
}
+
protected function _buildNewProductRequest(
\Magento\Catalog\Model\Product $product,
$mailchimpStoreId,
$magentoStoreId
) {
-
$variantProducts = [];
switch ($product->getTypeId()) {
case \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE:
@@ -277,14 +299,14 @@ protected function _buildNewProductRequest(
return [];
}
$bodyData = $this->_buildProductData($product, $magentoStoreId, false, $variantProducts);
- $body = json_encode($bodyData, JSON_HEX_APOS|JSON_HEX_QUOT);
+ $body = json_encode($bodyData, JSON_HEX_APOS | JSON_HEX_QUOT);
if ($body === false) {
$jsonError = json_last_error();
$jsonErrorMsg = json_last_error_msg();
$this->_helper->log("");
- $this->_helper->log("$jsonErrorMsg for product [".$product->getId()."]");
- return [];
+ $this->_helper->log("$jsonErrorMsg for product [" . $product->getId() . "]");
+ return [];
} else {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::PRO_NEW);
$data = [];
@@ -294,8 +316,10 @@ protected function _buildNewProductRequest(
$data['body'] = $body;
$this->productPrice = null;
}
+
return $data;
}
+
protected function _buildOldProductRequest(
\Magento\Catalog\Model\Product $product,
$batchId,
@@ -307,7 +331,7 @@ protected function _buildOldProductRequest(
if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE ||
$product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL ||
$product->getTypeId() == "downloadable") {
- $data = $this-> _buildProductData($product, $magentoStoreId);
+ $data = $this->_buildProductData($product, $magentoStoreId);
$variantProducts [] = $product;
// $parentIds = $product->getTypeInstance()->getParentIdsByChild($product->getId());
$parentIds = $this->_configurable->getParentIdsByChild($product->getId());
@@ -336,10 +360,10 @@ protected function _buildOldProductRequest(
$parentId . '/variants/' . $data['id'];
$productdata['operation_id'] = $batchId . '_' . $parentId;
$body = json_encode($variendata);
- if ($body===false) {
+ if ($body === false) {
$jsonErrorMsg = json_last_error_msg();
$this->_helper->log("");
- $this->_helper->log("$jsonErrorMsg for product [".$product->getId()."]");
+ $this->_helper->log("$jsonErrorMsg for product [" . $product->getId() . "]");
continue;
}
$productdata['body'] = $body;
@@ -359,30 +383,32 @@ protected function _buildOldProductRequest(
}
$bodyData = $this->_buildProductData($product, $magentoStoreId, false, $variantProducts);
- $body = json_encode($bodyData, JSON_HEX_APOS|JSON_HEX_QUOT);
- if ($body===false) {
+ $body = json_encode($bodyData, JSON_HEX_APOS | JSON_HEX_QUOT);
+ if ($body === false) {
$jsonErrorMsg = json_last_error_msg();
$this->_helper->log("");
- $this->_helper->log("$jsonErrorMsg for product [".$product->getId()."]");
+ $this->_helper->log("$jsonErrorMsg for product [" . $product->getId() . "]");
+
return [];
}
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::PRO_MOD);
$data = [];
$data['method'] = "PATCH";
- $data['path'] = "/ecommerce/stores/" . $mailchimpStoreId . "/products/".$product->getId();
+ $data['path'] = "/ecommerce/stores/" . $mailchimpStoreId . "/products/" . $product->getId();
$data['operation_id'] = $this->_batchId . '_' . $product->getId();
$data['body'] = $body;
$operations[] = $data;
$this->productPrice = null;
+
return $operations;
}
+
protected function _buildProductData(
\Magento\Catalog\Model\Product $product,
$magentoStoreId,
$isVarient = true,
$variants = null
) {
-
$data = [];
$parent = null;
@@ -391,22 +417,22 @@ protected function _buildProductData(
$data["title"] = $product->getName();
$data["url"] = $product->getProductUrl();
$data["image_url"] = '';
- if ($product->getImage() && $product->getImage()!='no_selection') {
- $filePath = 'catalog/product/'.ltrim($product->getImage(), '/');
+ if ($product->getImage() && $product->getImage() != 'no_selection') {
+ $filePath = 'catalog/product/' . ltrim($product->getImage(), '/');
$data["image_url"] = $this->_helper->getBaserUrl(
- $magentoStoreId,
- \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
- ).$filePath;
+ $magentoStoreId,
+ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
+ ) . $filePath;
} elseif ($this->_parentImage) {
$data['image_url'] = $this->_parentImage;
} else {
$parent = $this->_getParent($product->getId(), $magentoStoreId);
- if ($parent && $parent->getImage() && $parent->getImage()!='no_selection') {
- $filePath = 'catalog/product/'.ltrim($parent->getImage(), '/');
+ if ($parent && $parent->getImage() && $parent->getImage() != 'no_selection') {
+ $filePath = 'catalog/product/' . ltrim($parent->getImage(), '/');
$data["image_url"] = $this->_helper->getBaserUrl(
- $magentoStoreId,
- \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
- ).$filePath;
+ $magentoStoreId,
+ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
+ ) . $filePath;
}
}
$data["published_at_foreign"] = "";
@@ -441,11 +467,11 @@ protected function _buildProductData(
}
$this->_childtUrl = $data['url'] = $parent->getProductUrl() . $tailUrl;
if (empty($data['image_url'])) {
- $filePath = 'catalog/product'.$parent->getImage();
+ $filePath = 'catalog/product' . $parent->getImage();
$data["image_url"] = $this->_helper->getBaserUrl(
- $magentoStoreId,
- \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
- ).$filePath;
+ $magentoStoreId,
+ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
+ ) . $filePath;
}
}
} else {
@@ -509,7 +535,7 @@ protected function _buildProductData(
protected function _getParent($productId, $magentoStoreId)
{
- $parentIds =$this->_configurable->getParentIdsByChild($productId);
+ $parentIds = $this->_configurable->getParentIdsByChild($productId);
$parent = null;
foreach ($parentIds as $id) {
$parent = $this->_productRepository->getById($id, false, $magentoStoreId);
@@ -519,6 +545,7 @@ protected function _getParent($productId, $magentoStoreId)
$parent = null;
}
}
+
return $parent;
}
@@ -535,16 +562,18 @@ protected function getProductCategories(\Magento\Catalog\Model\Product $product,
$collection = $this->_categoryCollection->create();
$collection->addAttributeToSelect(['name'])
->setStoreId($storeId)
- ->addAttributeToFilter('is_active', ['eq'=>'1'])
- ->addAttributeToFilter('entity_id', ['in'=>$categoryIds])
+ ->addAttributeToFilter('is_active', ['eq' => '1'])
+ ->addAttributeToFilter('entity_id', ['in' => $categoryIds])
->addAttributeToSort('level', 'asc');
foreach ($collection as $category) {
$categoryNames[] = $category->getName();
}
$categoryName = (count($categoryNames)) ? implode(" - ", $categoryNames) : 'None';
}
+
return $categoryName;
}
+
/**
* @param \Magento\Sales\Model\Order $order
* @param $mailchimpStoreId
@@ -568,10 +597,13 @@ public function sendModifiedProduct(\Magento\Sales\Model\Order $order, $mailchim
if ($product->getId() != $item->getProductId() || (
$product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE &&
$product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL &&
- $product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE &&
+ $product->getTypeId(
+ ) != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE &&
$product->getTypeId() != "downloadable")) {
- $this->_helper->log('The product with id [' . $product->getId() .
- '] is not supported [' . $product->getTypeId() . ']');
+ $this->_helper->log(
+ 'The product with id [' . $product->getId() .
+ '] is not supported [' . $product->getTypeId() . ']'
+ );
continue;
}
if ($productSyncData->getMailchimpSyncModified() &&
@@ -588,9 +620,10 @@ public function sendModifiedProduct(\Magento\Sales\Model\Order $order, $mailchim
}
} catch (\Exception $e) {
$this->_helper->log($e->getMessage());
- $this->_helper->log("Skip product [".$item->getProductId()."]");
+ $this->_helper->log("Skip product [" . $item->getProductId() . "]");
}
}
+
return $data;
}
@@ -610,13 +643,13 @@ public function sendQuoteModifiedProduct(\Magento\Quote\Model\Quote $quote, $mai
$product->getId(),
\Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT
);
- if ($product->getId()!=$item->getProductId() || (
+ if ($product->getId() != $item->getProductId() || (
$product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE &&
$product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL &&
$product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE &&
$product->getTypeId() != "downloadable")) {
$this->_helper->log(
- 'The product with id ['.$product->getId().'] is not supported ['.$product->getTypeId().']'
+ 'The product with id [' . $product->getId() . '] is not supported [' . $product->getTypeId() . ']'
);
continue;
}
@@ -634,8 +667,10 @@ public function sendQuoteModifiedProduct(\Magento\Quote\Model\Quote $quote, $mai
$this->_updateProduct($mailchimpStoreId, $product->getId());
}
}
+
return $data;
}
+
protected function _getProductPrice(\Magento\Catalog\Model\Product $product)
{
if ($this->includingTaxes) {
@@ -643,8 +678,10 @@ protected function _getProductPrice(\Magento\Catalog\Model\Product $product)
} else {
$price = $this->taxHelper->getTaxPrice($product, $product->getFinalPrice(), false);
}
+
return $price;
}
+
/**
* @param $storeId
* @param $entityId
diff --git a/Model/Api/PromoCodes.php b/Model/Api/PromoCodes.php
index ab142452..afbc22c6 100644
--- a/Model/Api/PromoCodes.php
+++ b/Model/Api/PromoCodes.php
@@ -1,19 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/6/17 1:15 PM
- * @file: Coupon.php
- */
+
namespace Ebizmarts\MailChimp\Model\Api;
-use Magento\TestFramework\Inspection\Exception;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\TestFramework\Inspection\Exception;
class PromoCodes
{
@@ -67,17 +57,17 @@ public function __construct(
\Ebizmarts\MailChimp\Model\Api\PromoRules $promoRules,
\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $syncCollection
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_couponCollection = $couponCollection;
- $this->_ruleCollection = $ruleCollection;
- $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE. '_' .
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_couponCollection = $couponCollection;
+ $this->_ruleCollection = $ruleCollection;
+ $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE . '_' .
$this->_helper->getGmtTimeStamp();
- $this->_promoRules = $promoRules;
- $this->_syncCollection = $syncCollection;
+ $this->_promoRules = $promoRules;
+ $this->_syncCollection = $syncCollection;
}
+
public function sendCoupons($magentoStoreId)
{
$mailchimpStoreId = $this->_helper->getConfigValue(
@@ -91,14 +81,15 @@ public function sendCoupons($magentoStoreId)
return $batchArray;
}
+
protected function _sendDeletedCoupons($mailchimpStoreId, $magentoStoreId)
{
$batchArray = [];
$websiteId = $this->_helper->getWebsiteId($magentoStoreId);
$collection = $this->_syncCollection->create();
- $collection->addFieldToFilter('mailchimp_store_id', ['eq'=>$mailchimpStoreId])
- ->addFieldToFilter('type', ['eq'=>\Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE])
- ->addFieldToFilter('mailchimp_sync_deleted', ['eq'=>1]);
+ $collection->addFieldToFilter('mailchimp_store_id', ['eq' => $mailchimpStoreId])
+ ->addFieldToFilter('type', ['eq' => \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE])
+ ->addFieldToFilter('mailchimp_sync_deleted', ['eq' => 1]);
$collection->getSelect()->limit(self::MAX);
$counter = 0;
/**
@@ -112,15 +103,17 @@ protected function _sendDeletedCoupons($mailchimpStoreId, $magentoStoreId)
$batchArray[$counter]['path'] =
"/ecommerce/stores/$mailchimpStoreId/promo-rules/$ruleId/promo-codes/$couponId";
$counter++;
- $syncCoupon =$this->syncHelper->getChimpSyncEcommerce(
+ $syncCoupon = $this->syncHelper->getChimpSyncEcommerce(
$mailchimpStoreId,
$couponId,
\Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE
);
$syncCoupon->getResource()->delete($syncCoupon);
}
+
return $batchArray;
}
+
protected function _sendNewCoupons($mailchimpStoreId, $magentoStoreId)
{
$batchArray = [];
@@ -148,7 +141,9 @@ protected function _sendNewCoupons($mailchimpStoreId, $magentoStoreId)
['rules' => $this->_helper->getTableName('salesrule')],
'main_table.rule_id = rules.rule_id'
);
- $collection->getSelect()->where("m4m.mailchimp_sync_delta IS null and (rules.use_auto_generation = 1 and main_table.is_primary is null or rules.use_auto_generation = 0 and main_table.is_primary = 1) and main_table.rule_id in ($inRoules)");
+ $collection->getSelect()->where(
+ "m4m.mailchimp_sync_delta IS null and (rules.use_auto_generation = 1 and main_table.is_primary is null or rules.use_auto_generation = 0 and main_table.is_primary = 1) and main_table.rule_id in ($inRoules)"
+ );
$collection->getSelect()->limit(self::MAX);
$counter = 0;
/**
@@ -235,8 +230,10 @@ protected function _sendNewCoupons($mailchimpStoreId, $magentoStoreId)
}
}
}
+
return $batchArray;
}
+
protected function generateCodeData($item, $magentoStoreId)
{
$data = [];
@@ -247,13 +244,16 @@ protected function generateCodeData($item, $magentoStoreId)
return $data;
}
+
protected function _getRedemptionUrl($code, $magentoStoreId)
{
$token = hash('md5', rand(0, 9999999));
$url = $this->_helper->getRedemptionUrl($magentoStoreId, $code, $token);
$this->_token = $token;
+
return $url;
}
+
protected function _updateSyncData(
$storeId,
$entityId,
diff --git a/Model/Api/PromoRules.php b/Model/Api/PromoRules.php
index 72ebf0e6..06fa9afd 100644
--- a/Model/Api/PromoRules.php
+++ b/Model/Api/PromoRules.php
@@ -1,22 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/17/17 2:38 PM
- * @file: PromoRules.php
- */
namespace Ebizmarts\MailChimp\Model\Api;
-use Magento\Cms\Test\Unit\Controller\Adminhtml\Page\MassEnableTest;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
-
class PromoRules
{
const TYPE_FIXED = 'fixed';
@@ -71,16 +58,16 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $chimpSyncEcommerce,
\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $syncCollection
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_collection = $collection;
- $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
- $this->_ruleRepo = $ruleRepo;
- $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE. '_' .
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_collection = $collection;
+ $this->_chimpSyncEcommerce = $chimpSyncEcommerce;
+ $this->_ruleRepo = $ruleRepo;
+ $this->_batchId = \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE . '_' .
$this->_helper->getGmtTimeStamp();
- $this->_syncCollection = $syncCollection;
+ $this->_syncCollection = $syncCollection;
}
+
public function sendRules($magentoStoreId)
{
$mailchimpStoreId = $this->_helper->getConfigValue(
@@ -91,15 +78,17 @@ public function sendRules($magentoStoreId)
$batchArray = array_merge($batchArray, $this->_getDeletedPromoRules($mailchimpStoreId, $magentoStoreId));
$batchArray = array_merge($batchArray, $this->_getModifiedPromoRules($mailchimpStoreId, $magentoStoreId));
+
return $batchArray;
}
+
protected function _getDeletedPromoRules($mailchimpStoreId, $magentoStoreId)
{
$batchArray = [];
$collection = $this->_syncCollection->create();
- $collection->addFieldToFilter('mailchimp_store_id', ['eq'=>$mailchimpStoreId])
- ->addFieldToFilter('type', ['eq'=>\Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE])
- ->addFieldToFilter('mailchimp_sync_deleted', ['eq'=>1]);
+ $collection->addFieldToFilter('mailchimp_store_id', ['eq' => $mailchimpStoreId])
+ ->addFieldToFilter('type', ['eq' => \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE])
+ ->addFieldToFilter('mailchimp_sync_deleted', ['eq' => 1]);
$collection->getSelect()->limit(self::MAX);
$count = 0;
$api = $this->_helper->getApi($magentoStoreId);
@@ -130,8 +119,10 @@ protected function _getDeletedPromoRules($mailchimpStoreId, $magentoStoreId)
$mailchimpStoreId
);
}
+
return $batchArray;
}
+
protected function _getModifiedPromoRules($mailchimpStoreId, $magentoStoreId)
{
$batchArray = [];
@@ -143,9 +134,9 @@ protected function _getModifiedPromoRules($mailchimpStoreId, $magentoStoreId)
$collection->addWebsiteFilter($websiteId);
$collection->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.rule_id and m4m.type = '".
- \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE.
- "' and m4m.mailchimp_store_id = '".$mailchimpStoreId."'",
+ "m4m.related_id = main_table.rule_id and m4m.type = '" .
+ \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE .
+ "' and m4m.mailchimp_store_id = '" . $mailchimpStoreId . "'",
['m4m.*']
);
$collection->getSelect()->where("m4m.mailchimp_sync_modified = 1");
@@ -176,11 +167,13 @@ protected function _getModifiedPromoRules($mailchimpStoreId, $magentoStoreId)
);
$batchArray[$count]['method'] = 'DELETE';
$batchArray[$count]['path'] = "/ecommerce/stores/$mailchimpStoreId/promo-rules/$ruleId";
- $batchArray[$count]['operation_id'] = $this->_batchId. '_' . $rule->getRuleId();
+ $batchArray[$count]['operation_id'] = $this->_batchId . '_' . $rule->getRuleId();
$count++;
}
+
return $batchArray;
}
+
public function getNewPromoRule($ruleId, $mailchimpStoreId, $magentoStoreId)
{
$data = [];
@@ -232,6 +225,7 @@ public function getNewPromoRule($ruleId, $mailchimpStoreId, $magentoStoreId)
} catch (\Exception $e) {
$this->_helper->log($e->getMessage());
}
+
return $data;
}
@@ -255,10 +249,10 @@ private function _generateRuleData($rule)
$data['target'] = $this->_getMailChimpTarget($promoAction, $shipping);
switch ($data['type']) {
case self::TYPE_PERCENTAGE:
- $data['amount'] = $rule->getDiscountAmount()/100;
+ $data['amount'] = $rule->getDiscountAmount() / 100;
break;
case self::TYPE_FIXED:
- if ($data['target']!=self::TARGET_SHIPPING) {
+ if ($data['target'] != self::TARGET_SHIPPING) {
$data['amount'] = $rule->getDiscountAmount();
} else {
$data['amount'] = 0;
@@ -280,7 +274,7 @@ private function _generateRuleData($rule)
private function _getMailChimpType($action, $shipping)
{
$mailChimpType = null;
- if ($shipping==self::FREESHIPPING_NO) {
+ if ($shipping == self::FREESHIPPING_NO) {
switch ($action) {
case \Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION:
$mailChimpType = self::TYPE_PERCENTAGE;
@@ -293,6 +287,7 @@ private function _getMailChimpType($action, $shipping)
} else {
$mailChimpType = self::TYPE_FIXED;
}
+
return $mailChimpType;
}
@@ -303,7 +298,7 @@ private function _getMailChimpType($action, $shipping)
private function _getMailChimpTarget($action, $shipping)
{
$mailChimpTarget = null;
- if ($shipping==self::FREESHIPPING_NO) {
+ if ($shipping == self::FREESHIPPING_NO) {
switch ($action) {
case \Magento\SalesRule\Model\Rule::CART_FIXED_ACTION:
case \Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION:
@@ -316,6 +311,7 @@ private function _getMailChimpTarget($action, $shipping)
} else {
$mailChimpTarget = self::TARGET_SHIPPING;
}
+
return $mailChimpTarget;
}
diff --git a/Model/Api/Result.php b/Model/Api/Result.php
index 0d2aac57..a5a28a49 100644
--- a/Model/Api/Result.php
+++ b/Model/Api/Result.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/21/16 4:09 PM
- * @file: Result.php
- */
namespace Ebizmarts\MailChimp\Model\Api;
@@ -65,16 +54,16 @@ public function __construct(
\Magento\Framework\Filesystem\Driver\File $driver,
\Magento\Framework\HTTP\Client\CurlFactory $curlFactory
) {
-
- $this->_batchCollection = $batchCollection;
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_archive = $archive;
- $this->_chimpErrors = $chimpErrors;
- $this->_driver = $driver;
- $this->_curlFactory = $curlFactory;
+ $this->_batchCollection = $batchCollection;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_archive = $archive;
+ $this->_chimpErrors = $chimpErrors;
+ $this->_driver = $driver;
+ $this->_curlFactory = $curlFactory;
}
- public function processResponses($storeId, $isMailChimpStoreId = false, $mailchimpStoreId=null)
+
+ public function processResponses($storeId, $isMailChimpStoreId = false, $mailchimpStoreId = null)
{
$collection = $this->_batchCollection->create();
$collection
@@ -100,28 +89,33 @@ public function processResponses($storeId, $isMailChimpStoreId = false, $mailchi
continue;
}
$baseDir = $this->_helper->getBaseDir();
- if ($this->_driver->isDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $item->getBatchId())) {
+ if ($this->_driver->isDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $item->getBatchId()
+ )) {
$dirFiles = $this->_driver->readDirectory(
$baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR .
- $item->getBatchId().DIRECTORY_SEPARATOR
+ $item->getBatchId() . DIRECTORY_SEPARATOR
);
foreach ($dirFiles as $dirFile) {
$this->_driver->deleteFile(
$baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR .
- $item->getBatchId().DIRECTORY_SEPARATOR.$dirFile
+ $item->getBatchId() . DIRECTORY_SEPARATOR . $dirFile
);
}
- $this->_driver->deleteDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $item->getBatchId());
+ $this->_driver->deleteDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $item->getBatchId()
+ );
}
} catch (\Exception $e) {
$this->_helper->log("Error with a response: " . $e->getMessage());
}
}
}
+
public function getBatchResponse($batchId, $storeId = null)
{
$files = [];
@@ -135,8 +129,12 @@ public function getBatchResponse($batchId, $storeId = null)
if (isset($response['status']) && $response['status'] == 'finished') {
// Create temporary directory, if that does not exist
- if (!$this->_driver->isDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . self::MAILCHIMP_TEMP_DIR)) {
- $this->_driver->createDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . self::MAILCHIMP_TEMP_DIR);
+ if (!$this->_driver->isDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . self::MAILCHIMP_TEMP_DIR
+ )) {
+ $this->_driver->createDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . self::MAILCHIMP_TEMP_DIR
+ );
}
// get the tar.gz file with the results
// for AWS S3 use urldecode, for google drive use without urldecode
@@ -147,11 +145,13 @@ public function getBatchResponse($batchId, $storeId = null)
$ch->setOption(CURLOPT_URL, $fileUrl);
$ch->setOption(CURLOPT_FILE, $fd);
$ch->setOption(CURLOPT_FOLLOWLOCATION, true);
- $r =$ch->get($fileUrl);
+ $r = $ch->get($fileUrl);
$this->_driver->fileClose($fd);
- $this->_driver->createDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId);
+ $this->_driver->createDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
+ );
$archive = $this->_archive;
$archive->unpack(
$fileName . '.tar.gz',
@@ -164,43 +164,54 @@ public function getBatchResponse($batchId, $storeId = null)
$baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
);
- $dirFiles = $this->_driver->readDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId);
+ $dirFiles = $this->_driver->readDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
+ );
foreach ($dirFiles as $dirFile) {
$name = pathinfo($dirFile);
if ($name['extension'] == 'json') {
$files[] = $dirFile;
}
}
- $this->_driver->deleteFile($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId . '/' . $batchId . '.tar');
+ $this->_driver->deleteFile(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId . '/' . $batchId . '.tar'
+ );
$this->_driver->deleteFile($fileName . '.tar.gz');
}
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
+
return false;
} catch (\Exception $e) {
$this->_helper->log("Something went wrong retrieving result for batch [$batchId]");
$this->_helper->log("Deleting temporary files, will retry the next run don't worry");
try {
- $this->_driver->deleteFile($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId . '/' . $batchId . '.tar');
+ $this->_driver->deleteFile(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId . '/' . $batchId . '.tar'
+ );
$this->_driver->deleteFile($fileName . '.tar.gz');
- $this->_driver->deleteDirectory($baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
- self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId);
- } catch(\Exception $e) {
+ $this->_driver->deleteDirectory(
+ $baseDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR .
+ self::MAILCHIMP_TEMP_DIR . DIRECTORY_SEPARATOR . $batchId
+ );
+ } catch (\Exception $e) {
$this->_helper->log($e->getMessage());
}
}
+
return $files;
}
+
protected function processEachResponseFile($files, $batchId, $mailchimpStoreId, $storeId)
{
$listId = $this->_helper->getDefaultList($storeId);
foreach ($files as $file) {
$items = json_decode($this->_driver->fileGetContents($file));
- if ($items!==false) {
+ if ($items !== false) {
foreach ($items as $item) {
$line = explode('_', $item->operation_id);
$type = $line[0];
@@ -242,12 +253,12 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId,
$error,
\Ebizmarts\MailChimp\Helper\Data::SYNCERROR
);
- if (property_exists($response, 'type')){
+ if (property_exists($response, 'type')) {
$mailchimpErrors->setType($response->type);
} else {
$mailchimpErrors->setType('Unknown');
}
- if (property_exists($response, 'title')){
+ if (property_exists($response, 'title')) {
$mailchimpErrors->setTitle($response->title);
} else {
$mailchimpErrors->setTitle('Unknown');
@@ -292,6 +303,7 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId,
$this->_driver->deleteFile($file);
}
}
+
private function _updateSyncData($mailchimpStoreId, $listId, $type, $id, $error, $status)
{
/**
diff --git a/Model/Api/Subscriber.php b/Model/Api/Subscriber.php
index 530335fd..5d54a3b9 100644
--- a/Model/Api/Subscriber.php
+++ b/Model/Api/Subscriber.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/15/17 11:02 AM
- * @file: Subscriber.php
- */
+
namespace Ebizmarts\MailChimp\Model\Api;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
@@ -37,7 +27,7 @@ class Subscriber
* @var SyncHelper
*/
private $syncHelper;
- protected $_interest=null;
+ protected $_interest = null;
/**
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -53,12 +43,11 @@ public function __construct(
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Magento\Framework\Message\ManagerInterface $message
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->_subscriberCollection = $subscriberCollection;
- $this->_message = $message;
- $this->_subscriberFactory = $subscriberFactory;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->_subscriberCollection = $subscriberCollection;
+ $this->_message = $message;
+ $this->_subscriberFactory = $subscriberFactory;
}
public function sendSubscribers($storeId, $listId)
@@ -71,14 +60,16 @@ public function sendSubscribers($storeId, $listId)
->addFieldToFilter('store_id', ['eq' => $storeId]);
$collection->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
- "m4m.related_id = main_table.subscriber_id and m4m.type = '".
- \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER.
- "' and m4m.mailchimp_store_id = '".$listId."'",
+ "m4m.related_id = main_table.subscriber_id and m4m.type = '" .
+ \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER .
+ "' and m4m.mailchimp_store_id = '" . $listId . "'",
['m4m.*']
);
- $collection->getSelect()->where("m4m.mailchimp_sync_delta IS null ".
- "OR (m4m.mailchimp_sync_delta > '".$this->_helper->getMCMinSyncDateFlag().
- "' and m4m.mailchimp_sync_modified = 1)");
+ $collection->getSelect()->where(
+ "m4m.mailchimp_sync_delta IS null " .
+ "OR (m4m.mailchimp_sync_delta > '" . $this->_helper->getMCMinSyncDateFlag() .
+ "' and m4m.mailchimp_sync_modified = 1)"
+ );
$collection->getSelect()->limit(self::BATCH_LIMIT);
$subscriberArray = [];
$date = $this->_helper->getDateMicrotime();
@@ -93,7 +84,7 @@ public function sendSubscribers($storeId, $listId)
$subscriberJson = "";
//enconde to JSON
$subscriberJson = json_encode($data);
- if ($subscriberJson!==false) {
+ if ($subscriberJson !== false) {
if (!empty($subscriberJson)) {
if ($subscriber->getMailchimpSyncModified() == 1) {
$this->_helper->modifyCounter(\Ebizmarts\MailChimp\Helper\Data::SUB_MOD);
@@ -119,6 +110,7 @@ public function sendSubscribers($storeId, $listId)
);
}
}
+
return $subscriberArray;
}
@@ -139,6 +131,7 @@ protected function _buildSubscriberData(\Magento\Newsletter\Model\Subscriber $su
return $data;
}
+
protected function _getInterest(\Magento\Newsletter\Model\Subscriber $subscriber)
{
$rc = [];
@@ -154,11 +147,12 @@ protected function _getInterest(\Magento\Newsletter\Model\Subscriber $subscriber
}
}
}
+
return $rc;
}
+
/**
* Get status to send confirmation if Need to Confirm enabled on Magento
- *
* @param $status
* @param $storeId
* @return string
@@ -176,8 +170,10 @@ protected function _getMCStatus($status, $storeId)
} elseif ($status == \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED) {
$status = 'subscribed';
}
+
return $status;
}
+
public function deleteSubscriber(\Magento\Newsletter\Model\Subscriber $subscriber)
{
$storeId = $subscriber->getStoreId();
@@ -193,6 +189,7 @@ public function deleteSubscriber(\Magento\Newsletter\Model\Subscriber $subscribe
$this->_helper->log($e->getMessage(), $storeId);
}
}
+
public function update(\Magento\Newsletter\Model\Subscriber $subscriber)
{
$storeId = $subscriber->getStoreId();
@@ -205,6 +202,7 @@ public function update(\Magento\Newsletter\Model\Subscriber $subscriber)
1
);
}
+
protected function _updateSubscriber(
$listId,
$entityId,
diff --git a/Model/Config/Backend/ApiKey.php b/Model/Config/Backend/ApiKey.php
index a4b8382f..91fa008b 100644
--- a/Model/Config/Backend/ApiKey.php
+++ b/Model/Config/Backend/ApiKey.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 9/30/16 12:09 PM
- * @file: Monkeylist.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Backend;
@@ -35,7 +24,6 @@ class ApiKey extends \Magento\Framework\App\Config\Value
private $_storeManager;
/**
- * ApiKey constructor.
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param ScopeConfigInterface $config
@@ -61,10 +49,10 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
array $data = []
) {
- $this->_helper = $helper;
- $this->resourceConfig = $resourceConfig;
- $this->_date = $date;
- $this->_storeManager = $storeManager;
+ $this->_helper = $helper;
+ $this->resourceConfig = $resourceConfig;
+ $this->_date = $date;
+ $this->_storeManager = $storeManager;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
@@ -96,10 +84,11 @@ public function beforeSave()
$found++;
}
}
- if ($found==1) {
+ if ($found == 1) {
$this->_helper->cancelAllPendingBatches($mailchimpStore);
}
}
+
return parent::beforeSave();
}
}
diff --git a/Model/Config/Backend/MonkeyList.php b/Model/Config/Backend/MonkeyList.php
index 3e68c172..524b0c13 100644
--- a/Model/Config/Backend/MonkeyList.php
+++ b/Model/Config/Backend/MonkeyList.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/22/17 3:08 PM
- * @file: MonkeyList.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Backend;
@@ -33,7 +22,6 @@ class MonkeyList extends \Magento\Framework\App\Config\Value
private $_storeManager;
/**
- * ApiKey constructor.
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param ScopeConfigInterface $config
@@ -59,10 +47,10 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
array $data = []
) {
- $this->_helper = $helper;
- $this->resourceConfig = $resourceConfig;
- $this->_date = $date;
- $this->_storeManager = $storeManager;
+ $this->_helper = $helper;
+ $this->resourceConfig = $resourceConfig;
+ $this->_date = $date;
+ $this->_storeManager = $storeManager;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
}
diff --git a/Model/Config/Backend/MonkeyStore.php b/Model/Config/Backend/MonkeyStore.php
index a185729f..1ac20bab 100644
--- a/Model/Config/Backend/MonkeyStore.php
+++ b/Model/Config/Backend/MonkeyStore.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/29/17 4:29 PM
- * @file: MonkeyStore.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Backend;
@@ -69,11 +58,11 @@ public function __construct(
\Magento\Store\Model\StoreManager $storeManager,
array $data = []
) {
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->resourceConfig = $resourceConfig;
- $this->_date = $date;
- $this->_storeManager = $storeManager;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->resourceConfig = $resourceConfig;
+ $this->_date = $date;
+ $this->_storeManager = $storeManager;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
@@ -90,7 +79,7 @@ public function beforeSave()
$active = 0;
}
if ($active && $this->isValueChanged()) {
- $mailchimpStore = $this->getOldValue();
+ $mailchimpStore = $this->getOldValue();
// charge the $newListId
if (isset($data['general']['fields']['apikey']['value'])) {
$apiKey = $data['general']['fields']['apikey']['value'];
@@ -138,7 +127,7 @@ public function beforeSave()
$createWebhook = false;
}
}
- if ($found==1) {
+ if ($found == 1) {
$this->_helper->cancelAllPendingBatches($mailchimpStore);
$this->syncHelper->resetErrors($mailchimpStore, $this->getScopeId(), true);
}
@@ -147,17 +136,21 @@ public function beforeSave()
$this->_helper->createWebHook($apiKey, $newListId);
}
}
+
return parent::beforeSave();
}
+
private function getStore($apiKey, $store)
{
try {
$api = $this->_helper->getApiByApiKey($apiKey);
$store = $api->ecommerce->stores->get($store);
+
return $store['list_id'];
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
+
return null;
}
}
diff --git a/Model/Config/Backend/VarsMap.php b/Model/Config/Backend/VarsMap.php
index f1967d19..6fe9d1f3 100644
--- a/Model/Config/Backend/VarsMap.php
+++ b/Model/Config/Backend/VarsMap.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/30/17 10:27 AM
- * @file: VarsMap.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Backend;
@@ -25,7 +14,6 @@ class VarsMap extends \Magento\Framework\App\Config\Value
private $_helper;
/**
- * VarsMap constructor.
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
@@ -47,11 +35,11 @@ public function __construct(
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
-
$this->_varsHelper = $varsMap;
- $this->_helper = $helper;
+ $this->_helper = $helper;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
+
protected function _afterLoad()
{
$value = $this->getValue();
@@ -61,7 +49,6 @@ protected function _afterLoad()
/**
* Prepare data before save
- *
* @return void
*/
public function beforeSave()
diff --git a/Model/Config/ModuleVersion.php b/Model/Config/ModuleVersion.php
index cf8a129a..3a45f24a 100644
--- a/Model/Config/ModuleVersion.php
+++ b/Model/Config/ModuleVersion.php
@@ -1,7 +1,6 @@
@@ -29,7 +28,6 @@ class ModuleVersion
private $readFactory;
/**
- * ModuleVersion constructor.
* @param ComponentRegistrarInterface $componentRegistrar
* @param ReadFactory $readFactory
*/
@@ -38,7 +36,8 @@ public function __construct(ComponentRegistrarInterface $componentRegistrar, Rea
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
}
- public function getModuleVersion($moduleName) : string
+
+ public function getModuleVersion($moduleName): string
{
$emptyVersionNumber = '';
$composerJsonData = null;
@@ -55,6 +54,7 @@ public function getModuleVersion($moduleName) : string
if ($jsonData === null) {
return $emptyVersionNumber;
}
+
return $jsonData->version ?? $emptyVersionNumber;
}
}
diff --git a/Model/Config/Source/ApiKey.php b/Model/Config/Source/ApiKey.php
index 697a18c8..35d5c037 100644
--- a/Model/Config/Source/ApiKey.php
+++ b/Model/Config/Source/ApiKey.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/30/17 1:36 PM
- * @file: ApiKey.php
- */
+
namespace Ebizmarts\MailChimp\Model\Config\Source;
class ApiKey implements \Magento\Framework\Option\ArrayInterface
@@ -29,7 +19,6 @@ class ApiKey implements \Magento\Framework\Option\ArrayInterface
protected $encryptor;
/**
- * ApiKey constructor.
* @param \Magento\Store\Model\StoreManager $storeManager
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
@@ -44,8 +33,8 @@ public function __construct(
) {
$this->storeManager = $storeManager;
$this->helper = $helper;
- $this->encryptor = $encryptor;
- $storeId = (int) $request->getParam("store", 0);
+ $this->encryptor = $encryptor;
+ $storeId = (int)$request->getParam("store", 0);
if ($request->getParam('website', 0)) {
$scope = 'website';
$storeId = $request->getParam('website', 0);
@@ -56,21 +45,25 @@ public function __construct(
$scope = 'default';
}
}
+
public function toOptionArray()
{
$rc = [];
if (is_array($this->options) && count($this->options)) {
$rc[] = ['value' => -1, 'label' => 'Select one ApiKey'];
foreach ($this->options as $apiKey) {
- $rc[] = ['value'=> $this->encryptor->encrypt(trim($apiKey)), 'label' => $this->mask(trim($apiKey))];
+ $rc[] = ['value' => $this->encryptor->encrypt(trim($apiKey)), 'label' => $this->mask(trim($apiKey))];
}
}
+
return $rc;
}
+
public function getAllApiKeys()
{
$this->options = $this->helper->getAllApiKeys();
}
+
private function mask($str)
{
if (strlen($str) < 4) {
diff --git a/Model/Config/Source/Cmspage.php b/Model/Config/Source/Cmspage.php
index 1b03c21d..73d9e523 100644
--- a/Model/Config/Source/Cmspage.php
+++ b/Model/Config/Source/Cmspage.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 9/30/16 2:46 PM
- * @file: Cmspage.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -19,6 +8,7 @@ class Cmspage
* @var \Magento\Cms\Model\Page
*/
private $_page;
+
/**
* @param \Magento\Cms\Model\Page $page
*/
@@ -27,9 +17,11 @@ public function __construct(
) {
$this->_page = $page;
}
+
public function toOptionArray()
{
$pages = $this->_page->getCollection()->addOrder('title', 'asc');
+
return ['checkout/cart' => 'Shopping Cart (default page)'] + $pages->toOptionIdArray();
}
}
diff --git a/Model/Config/Source/Details.php b/Model/Config/Source/Details.php
index e7e0273f..0dce5875 100644
--- a/Model/Config/Source/Details.php
+++ b/Model/Config/Source/Details.php
@@ -1,14 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -21,7 +11,7 @@ class Details implements \Magento\Framework\Option\ArrayInterface
/**
* @var \Ebizmarts\MailChimp\Helper\Data
*/
- private $_helper = null;
+ private $_helper = null;
/**
* @var \Magento\Framework\Message\ManagerInterface
*/
@@ -30,7 +20,6 @@ class Details implements \Magento\Framework\Option\ArrayInterface
private $_error = '';
/**
- * Details constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\Message\ManagerInterface $message
* @param \Magento\Store\Model\StoreManager $storeManager
@@ -43,9 +32,9 @@ public function __construct(
\Magento\Framework\App\RequestInterface $request
) {
$this->_message = $message;
- $this->_helper = $helper;
+ $this->_helper = $helper;
$this->storeManager = $storeManager;
- $storeId = (int) $request->getParam("store", 0);
+ $storeId = (int)$request->getParam("store", 0);
if ($request->getParam('website', 0)) {
$scope = 'website';
$storeId = $request->getParam('website', 0);
@@ -77,7 +66,7 @@ public function __construct(
$storeId,
$scope
);
- if ($mailchimpStoreId && $mailchimpStoreId!=-1 &&
+ if ($mailchimpStoreId && $mailchimpStoreId != -1 &&
$this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ECOMMERCE_ACTIVE,
$storeId,
@@ -119,7 +108,8 @@ public function toOptionArray()
if (isset($this->_options['account_name'])) {
$ret = [
['label' => __('Username'), 'value' => $this->_options['account_name']],
- ['label' => 'Total Member Subscribers', 'value' => $this->_options['total_subscribers']]];
+ ['label' => 'Total Member Subscribers', 'value' => $this->_options['total_subscribers']]
+ ];
if (array_key_exists('list_subscribers', $this->_options)) {
$ret = array_merge(
$ret,
@@ -136,16 +126,19 @@ public function toOptionArray()
]);
if ($this->_options['is_syncing']) {
$ret = array_merge($ret, [
- ['label'=> __('This account is currently syncing'), 'value'=>'']
+ ['label' => __('This account is currently syncing'), 'value' => '']
]);
} else {
$ret = array_merge($ret, [
- ['label'=> __('Account Synced since'), 'value'=>$this->_options['date_sync']]
+ ['label' => __('Account Synced since'), 'value' => $this->_options['date_sync']]
]);
}
} else {
$ret = array_merge($ret, [
- ['label'=>'Ecommerce disabled, only subscribers will be synchronized (your orders, products,etc will be not synchronized)','value'=>'']
+ [
+ 'label' => 'Ecommerce disabled, only subscribers will be synchronized (your orders, products,etc will be not synchronized)',
+ 'value' => ''
+ ]
]);
}
}
@@ -156,12 +149,14 @@ public function toOptionArray()
} else {
$ret = [['label' => 'Important', 'value' => __($this->_options)]];
}
+
return $ret;
}
+
private function getDateSync($mailchimpStoreId)
{
return $this->_helper->getConfigValue(
- \Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC."/$mailchimpStoreId",
+ \Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC . "/$mailchimpStoreId",
0,
"default"
);
diff --git a/Model/Config/Source/Interest.php b/Model/Config/Source/Interest.php
index 92c603d8..b5e25245 100644
--- a/Model/Config/Source/Interest.php
+++ b/Model/Config/Source/Interest.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/13/17 12:07 PM
- * @file: Interest.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -18,7 +7,6 @@ class Interest implements \Magento\Framework\Option\ArrayInterface
private $options = null;
/**
- * Interest constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
*/
@@ -26,8 +14,7 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Framework\App\RequestInterface $request
) {
-
- $storeId = (int) $request->getParam("store", 0);
+ $storeId = (int)$request->getParam("store", 0);
if ($request->getParam('website', 0)) {
$scope = 'website';
$storeId = $request->getParam('website', 0);
@@ -56,17 +43,20 @@ public function toOptionArray()
if (is_array($this->options) && is_array($this->options['categories']) && count($this->options['categories'])) {
$rc = [];
foreach ($this->options['categories'] as $interest) {
- $rc[] = ['value'=> $interest['id'], 'label' => $interest['title']];
+ $rc[] = ['value' => $interest['id'], 'label' => $interest['title']];
}
} else {
$rc[] = ['value' => [], 'label' => __('---No Data---')];
}
+
return $rc;
}
+
public function toArray()
{
$rc = [];
$rc[$this->options['id']] = $this->options['name'];
+
return $rc;
}
}
diff --git a/Model/Config/Source/MonkeyList.php b/Model/Config/Source/MonkeyList.php
index 08798e0f..a9c00ccc 100644
--- a/Model/Config/Source/MonkeyList.php
+++ b/Model/Config/Source/MonkeyList.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/28/17 10:57 AM
- * @file: MonkeyStore.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -18,7 +7,6 @@ class MonkeyList implements \Magento\Framework\Option\ArrayInterface
private $options = null;
/**
- * MonkeyList constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
*/
@@ -26,7 +14,7 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Framework\App\RequestInterface $request
) {
- $storeId = (int) $request->getParam("store", 0);
+ $storeId = (int)$request->getParam("store", 0);
if ($request->getParam('website', 0)) {
$scope = 'website';
$storeId = $request->getParam('website', 0);
@@ -47,6 +35,7 @@ public function __construct(
}
}
}
+
public function toOptionArray()
{
if (is_array($this->options)) {
@@ -57,12 +46,15 @@ public function toOptionArray()
} else {
$rc[] = ['value' => 0, 'label' => __('---No Data---')];
}
+
return $rc;
}
+
public function toArray()
{
$rc = [];
$rc[$this->options['id']] = $this->options['name'];
+
return $rc;
}
}
diff --git a/Model/Config/Source/MonkeyStore.php b/Model/Config/Source/MonkeyStore.php
index 2a77ab1c..e4a47243 100644
--- a/Model/Config/Source/MonkeyStore.php
+++ b/Model/Config/Source/MonkeyStore.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/28/17 10:57 AM
- * @file: MonkeyStore.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -18,7 +7,6 @@ class MonkeyStore implements \Magento\Framework\Option\ArrayInterface
private $options = null;
/**
- * MonkeyStore constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
*/
@@ -26,7 +14,7 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Framework\App\RequestInterface $request
) {
- $storeId = (int) $request->getParam("store", 0);
+ $storeId = (int)$request->getParam("store", 0);
if ($request->getParam('website', 0)) {
$scope = 'website';
$storeId = $request->getParam('website', 0);
@@ -49,6 +37,7 @@ public function __construct(
}
}
}
+
public function toOptionArray()
{
if (is_array($this->options)) {
@@ -56,29 +45,32 @@ public function toOptionArray()
$rc[] = ['value' => -1, 'label' => 'Select one Mailchimp Store'];
foreach ($this->options['stores'] as $store) {
if ($store['platform'] == \Ebizmarts\MailChimp\Helper\Data::PLATFORM) {
- if ($store['list_id']=='') {
+ if ($store['list_id'] == '') {
continue;
}
if (isset($store['connected_site'])) {
$label = $store['name'];
} else {
- $label = $store['name'].' (Warning: not connected)';
+ $label = $store['name'] . ' (Warning: not connected)';
}
- $rc[] = ['value'=> $store['id'], 'label' => $label];
+ $rc[] = ['value' => $store['id'], 'label' => $label];
}
}
} else {
$rc[] = ['value' => 0, 'label' => __('---No Data---')];
}
+
return $rc;
}
+
public function toArray()
{
$rc = [];
foreach ($this->options['stores'] as $store) {
$rc[$store['id']] = $store['name'];
}
+
return $rc;
}
}
diff --git a/Model/Config/Source/Months.php b/Model/Config/Source/Months.php
index cb64e5b5..f03b082f 100644
--- a/Model/Config/Source/Months.php
+++ b/Model/Config/Source/Months.php
@@ -1,21 +1,11 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 15/09/22 12:07 PM
- * @file: Months.php
- */
+
namespace Ebizmarts\MailChimp\Model\Config\Source;
class Months implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
- return ["0" => __("No"), "1"=> "1", "2" =>"2", "3" => "3", "4" => "4"];
+ return ["0" => __("No"), "1" => "1", "2" => "2", "3" => "3", "4" => "4"];
}
}
diff --git a/Model/Config/Source/Timeout.php b/Model/Config/Source/Timeout.php
index 9fb468ca..f249938c 100644
--- a/Model/Config/Source/Timeout.php
+++ b/Model/Config/Source/Timeout.php
@@ -6,6 +6,6 @@ class Timeout implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
- return [10 => 10, 20=> 20, 30=>30];
+ return [10 => 10, 20 => 20, 30 => 30];
}
}
diff --git a/Model/Config/Source/WebhookDelete.php b/Model/Config/Source/WebhookDelete.php
index 204993b8..0dac3c93 100644
--- a/Model/Config/Source/WebhookDelete.php
+++ b/Model/Config/Source/WebhookDelete.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/31/17 11:26 AM
- * @file: WebhookDelete.php
- */
namespace Ebizmarts\MailChimp\Model\Config\Source;
@@ -18,8 +7,8 @@ class WebhookDelete implements \Magento\Framework\Option\ArrayInterface
public function toOptionArray()
{
return [
- ['value' => 0, 'label'=>__('Unsubscribe')],
- ['value' => 1, 'label'=>__('Delete subscriber')]
+ ['value' => 0, 'label' => __('Unsubscribe')],
+ ['value' => 1, 'label' => __('Delete subscriber')]
];
}
}
diff --git a/Model/Logger/Handler.php b/Model/Logger/Handler.php
index 332653ea..74258647 100644
--- a/Model/Logger/Handler.php
+++ b/Model/Logger/Handler.php
@@ -1,18 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Model\Logger;
-use Monolog;
-
class Handler extends \Magento\Framework\Logger\Handler\Base
{
/**
diff --git a/Model/Logger/Logger.php b/Model/Logger/Logger.php
index 07c3eb2e..d0f3f60c 100644
--- a/Model/Logger/Logger.php
+++ b/Model/Logger/Logger.php
@@ -1,13 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Model\Logger;
diff --git a/Model/MailChimpErrors.php b/Model/MailChimpErrors.php
index db43d9d5..ec02a61f 100644
--- a/Model/MailChimpErrors.php
+++ b/Model/MailChimpErrors.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/21/16 4:55 PM
- * @file: MailChimpErrors.php
- */
namespace Ebizmarts\MailChimp\Model;
@@ -19,11 +8,14 @@ protected function _construct()
{
$this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpErrors::class);
}
+
public function getByStoreIdType($storeId, $id, $type)
{
$this->getResource()->getByStoreIdType($this, $storeId, $id, $type);
+
return $this;
}
+
public function deleteByStorePeriod($storeId, $interval, $limit)
{
return $this->getResource()->deleteByStorePeriod($this, $storeId, $interval, $limit);
diff --git a/Model/MailChimpInterestGroup.php b/Model/MailChimpInterestGroup.php
index da84fc6f..49689ede 100644
--- a/Model/MailChimpInterestGroup.php
+++ b/Model/MailChimpInterestGroup.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/20/17 3:43 PM
- * @file: MailChimpInterestGroup.php
- */
namespace Ebizmarts\MailChimp\Model;
@@ -20,9 +9,11 @@ protected function _construct()
parent::_construct();
$this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpInterestGroup::class);
}
+
public function getBySubscriberIdStoreId($subscriberId, $storeId)
{
$this->getResource()->getBySubscriberIdStoreId($this, $subscriberId, $storeId);
+
return $this;
}
}
diff --git a/Model/MailChimpStores.php b/Model/MailChimpStores.php
index 15169f0b..a4ed27dd 100644
--- a/Model/MailChimpStores.php
+++ b/Model/MailChimpStores.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/21/16 4:55 PM
- * @file: MailChimpErrors.php
- */
namespace Ebizmarts\MailChimp\Model;
diff --git a/Model/MailChimpSyncBatches.php b/Model/MailChimpSyncBatches.php
index 4b6fd6c9..52156d3e 100644
--- a/Model/MailChimpSyncBatches.php
+++ b/Model/MailChimpSyncBatches.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/17/16 4:07 PM
- * @file: MailChimpSyncBatches.php
- */
+
namespace Ebizmarts\MailChimp\Model;
class MailChimpSyncBatches extends \Magento\Framework\Model\AbstractModel
diff --git a/Model/MailChimpSyncEcommerce.php b/Model/MailChimpSyncEcommerce.php
index 72880889..87e727f3 100644
--- a/Model/MailChimpSyncEcommerce.php
+++ b/Model/MailChimpSyncEcommerce.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/21/16 4:55 PM
- * @file: MailChimpSyncEcommerce.php
- */
namespace Ebizmarts\MailChimp\Model;
@@ -24,27 +13,36 @@ protected function _construct()
public function getByStoreIdType($storeId, $id, $type)
{
$this->getResource()->getByStoreIdType($this, $storeId, $id, $type);
+
return $this;
}
+
public function markAllAsDeleted($id, $type, $relatedDeletedId)
{
$this->getResource()->markAllAsDeleted($this, $id, $type, $relatedDeletedId);
+
return $this;
}
+
public function markAllAsModified($id, $type)
{
$this->getResource()->markAllAsModified($this, $id, $type);
+
return $this;
}
+
public function deleteAllByIdType($id, $type, $mailchimpStoreId)
{
$this->getResource()->deleteAllByIdType($this, $id, $type, $mailchimpStoreId);
+
return $this;
}
+
public function deleteAllByBatchid($batchId)
{
$this->getResource()->deleteAllByBatchid($this, $batchId);
}
+
public function markAllAsModifiedByIds($mailchimpStoreId, $ids, $type)
{
$this->getResource()->markAllAsModifiedByIds($this, $mailchimpStoreId, $ids, $type);
diff --git a/Model/MailChimpSyncEcommerceFactory.php b/Model/MailChimpSyncEcommerceFactory.php
index 6b73f7fb..f1cc69f0 100644
--- a/Model/MailChimpSyncEcommerceFactory.php
+++ b/Model/MailChimpSyncEcommerceFactory.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 2/28/17 7:24 PM
- * @file: MailChimpSyncEcommerceFactory.php
- */
namespace Ebizmarts\MailChimp\Model;
@@ -20,7 +9,6 @@ class MailChimpSyncEcommerceFactory
protected $_instanceName;
/**
- * MailChimpSyncEcommerceFactory constructor.
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $instanceName
*/
@@ -28,9 +16,8 @@ public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
$instanceName = \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce::class
) {
-
- $this->_objectManager = $objectManager;
- $this->_instanceName = $instanceName;
+ $this->_objectManager = $objectManager;
+ $this->_instanceName = $instanceName;
}
/**
diff --git a/Model/MailChimpWebhookRequest.php b/Model/MailChimpWebhookRequest.php
index 4ce0fb38..2c1e0e3b 100644
--- a/Model/MailChimpWebhookRequest.php
+++ b/Model/MailChimpWebhookRequest.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/26/17 11:32 AM
- * @file: MailChimpWebhookRequest.php
- */
namespace Ebizmarts\MailChimp\Model;
diff --git a/Model/Plugin/AccountManagement.php b/Model/Plugin/AccountManagement.php
index 981cca1a..b94d1f9b 100644
--- a/Model/Plugin/AccountManagement.php
+++ b/Model/Plugin/AccountManagement.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/24/17 5:33 PM
- * @file: AccountManagement.php
- */
namespace Ebizmarts\MailChimp\Model\Plugin;
@@ -33,7 +22,6 @@ class AccountManagement
protected $_storeManager;
/**
- * AccountManagement constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Quote\Model\QuoteFactory $quote
@@ -45,9 +33,8 @@ public function __construct(
\Magento\Quote\Model\QuoteFactory $quote,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
-
- $this->_helper = $helper;
- $this->_quote = $quote;
+ $this->_helper = $helper;
+ $this->_quote = $quote;
$this->_session = $checkoutSession;
$this->_storeManager = $storeManager;
}
@@ -64,7 +51,6 @@ public function aroundIsEmailAvailable(
$customerEmail,
$websiteId = null
) {
-
$ret = $proceed($customerEmail, $websiteId);
if ($this->_session && $this->_helper->isEmailSavingEnabled($this->_storeManager->getStore()->getId())) {
$quoteId = $this->_session->getQuoteId();
@@ -76,6 +62,7 @@ public function aroundIsEmailAvailable(
$quote->getResource()->save($quote);
}
}
- return$ret;
+
+ return $ret;
}
}
diff --git a/Model/Plugin/Coupon.php b/Model/Plugin/Coupon.php
index e53e9f0c..29ff59e0 100644
--- a/Model/Plugin/Coupon.php
+++ b/Model/Plugin/Coupon.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/23/17 1:32 PM
- * @file: Coupon.php
- */
namespace Ebizmarts\MailChimp\Model\Plugin;
@@ -28,9 +17,9 @@ class Coupon
public function __construct(
SyncHelper $synHelper
) {
-
- $this->synHelper = $synHelper;
+ $this->synHelper = $synHelper;
}
+
public function afterAfterDelete(\Magento\SalesRule\Model\Coupon $coupon)
{
$this->synHelper->markEcommerceAsDeleted(
diff --git a/Model/Plugin/Creditmemo.php b/Model/Plugin/Creditmemo.php
index 48045b1c..112c7814 100644
--- a/Model/Plugin/Creditmemo.php
+++ b/Model/Plugin/Creditmemo.php
@@ -1,19 +1,10 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- *
- */
+
namespace Ebizmarts\MailChimp\Model\Plugin;
-use Magento\Sales\Api\Data\CreditmemoInterface;
-use Magento\Sales\Api\CreditmemoRepositoryInterface as SalesCreditmemoRepositoryInterface;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\Sales\Api\CreditmemoRepositoryInterface as SalesCreditmemoRepositoryInterface;
+use Magento\Sales\Api\Data\CreditmemoInterface;
class Creditmemo
{
@@ -34,9 +25,10 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
- $this->_helper = $helper;
+ $this->_helper = $helper;
$this->syncHelper = $syncHelper;
}
+
public function afterSave(
SalesCreditmemoRepositoryInterface $subject,
CreditmemoInterface $creditmemo
diff --git a/Model/Plugin/Invoice.php b/Model/Plugin/Invoice.php
index 254211b1..f45ba7ef 100644
--- a/Model/Plugin/Invoice.php
+++ b/Model/Plugin/Invoice.php
@@ -1,14 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- *
- */
+
namespace Ebizmarts\MailChimp\Model\Plugin;
use Magento\Sales\Api\Data\InvoiceInterface;
diff --git a/Model/Plugin/Newsletter/Save.php b/Model/Plugin/Newsletter/Save.php
index 64e4b0a5..51d7dd85 100644
--- a/Model/Plugin/Newsletter/Save.php
+++ b/Model/Plugin/Newsletter/Save.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/27/17 8:14 PM
- * @file: Save.php
- */
namespace Ebizmarts\MailChimp\Model\Plugin\Newsletter;
@@ -58,14 +47,14 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
\Magento\Framework\App\Request\Http $request
) {
-
- $this->helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->customerSession = $customerSession;
- $this->subscriberFactory = $subscriberFactory;
- $this->request = $request;
+ $this->helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->customerSession = $customerSession;
+ $this->subscriberFactory = $subscriberFactory;
+ $this->request = $request;
$this->interestGroupFactory = $interestGroupFactory;
}
+
public function afterExecute()
{
$params = $this->request->getParams();
@@ -81,7 +70,7 @@ public function afterExecute()
try {
$subscriber->loadByCustomer($customer->getId(), $customer->getStoreId());
- if ($subscriber->getEmail()==$email) {
+ if ($subscriber->getEmail() == $email) {
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
$interestGroup->setGroupdata($this->helper->serialize($params));
$interestGroup->setSubscriberId($subscriber->getSubscriberId());
@@ -105,6 +94,7 @@ public function afterExecute()
$this->helper->log($params);
}
}
+
protected function _updateSubscriber(
$listId,
$entityId,
diff --git a/Model/Plugin/Quote.php b/Model/Plugin/Quote.php
index 76f9d062..808aee19 100644
--- a/Model/Plugin/Quote.php
+++ b/Model/Plugin/Quote.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/25/17 7:40 PM
- * @file: Quote.php
- */
+
namespace Ebizmarts\MailChimp\Model\Plugin;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
@@ -39,9 +29,8 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
-
$this->_cookieManager = $cookieManager;
- $this->_helper = $helper;
+ $this->_helper = $helper;
$this->syncHelper = $syncHelper;
}
diff --git a/Model/Plugin/Ship.php b/Model/Plugin/Ship.php
index 26275f6f..a0c405af 100644
--- a/Model/Plugin/Ship.php
+++ b/Model/Plugin/Ship.php
@@ -1,19 +1,10 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- *
- */
+
namespace Ebizmarts\MailChimp\Model\Plugin;
+use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
use Magento\Sales\Api\Data\ShipmentInterface;
use Magento\Sales\Model\Order\Shipment as SalesShipment;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class Ship
{
@@ -34,9 +25,10 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
- $this->_helper = $helper;
+ $this->_helper = $helper;
$this->syncHelper = $syncHelper;
}
+
public function afterSave(
SalesShipment $subject,
ShipmentInterface $shipment
@@ -56,6 +48,7 @@ public function afterSave(
null,
\Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC
);
+
return $shipment;
}
}
diff --git a/Model/Plugin/Subscriber.php b/Model/Plugin/Subscriber.php
index a8f2c7b1..f4e32f80 100644
--- a/Model/Plugin/Subscriber.php
+++ b/Model/Plugin/Subscriber.php
@@ -1,13 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Model\Plugin;
@@ -25,7 +16,6 @@ class Subscriber
protected $_api = null;
/**
- * Subscriber constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
*/
@@ -33,9 +23,8 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
-
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
}
/**
@@ -46,7 +35,6 @@ public function __construct(
public function afterDelete(
\Magento\Newsletter\Model\Subscriber $subscriber
) {
-
$storeId = $this->getStoreIdFromSubscriber($subscriber);
if ($this->_helper->isMailChimpEnabled($storeId)) {
$api = $this->_helper->getApi($storeId);
@@ -68,6 +56,7 @@ public function afterDelete(
}
}
}
+
return null;
}
@@ -103,7 +92,7 @@ public function afterLoadBySubscriberEmail(\Magento\Newsletter\Model\Subscriber
return $subscriber;
}
-
+
/**
* @param \Magento\Newsletter\Model\Subscriber $subscriber
* @param $customerId
diff --git a/Model/Plugin/SubscriptionManager.php b/Model/Plugin/SubscriptionManager.php
index b2f0a316..4a09bb19 100644
--- a/Model/Plugin/SubscriptionManager.php
+++ b/Model/Plugin/SubscriptionManager.php
@@ -1,22 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
namespace Ebizmarts\MailChimp\Model\Plugin;
+use Ebizmarts\MailChimp\Helper\Data as Helper;
+use Magento\Customer\Model\ResourceModel\CustomerRepository;
+use Magento\Customer\Model\Session;
use Magento\Newsletter\Model\SubscriberFactory;
-use \Ebizmarts\MailChimp\Helper\Data as Helper;
-use \Magento\Customer\Model\ResourceModel\CustomerRepository;
-use \Magento\Customer\Model\Session;
-use \Magento\Store\Model\StoreManagerInterface;
-
+use Magento\Store\Model\StoreManagerInterface;
class SubscriptionManager
{
@@ -40,7 +30,6 @@ class SubscriptionManager
protected $_api = null;
/**
- * SubscriptionManager constructor.
* @param Helper $helper
* @param CustomerRepository $customer
* @param Session $customerSession
@@ -54,13 +43,13 @@ public function __construct(
StoreManagerInterface $storeManager,
SubscriberFactory $subscriberFactory
) {
-
- $this->_helper = $helper;
- $this->_customer = $customer;
+ $this->_helper = $helper;
+ $this->_customer = $customer;
$this->_customerSession = $customerSession;
- $this->_storeManager = $storeManager;
+ $this->_storeManager = $storeManager;
$this->_subscriberFactory = $subscriberFactory;
}
+
/**
* @param \Magento\Newsletter\Model\Subscriber $subscriber
* @param $customerId
@@ -73,7 +62,6 @@ public function beforeUnsubscribeCustomer(
$storeId
) {
if ($this->_helper->isMailChimpEnabled($storeId)) {
-
$subscriber = $this->_subscriberFactory->create()->loadByCustomer($customerId, $storeId);
if ($subscriber->isSubscribed()) {
$api = $this->_helper->getApi($storeId);
@@ -90,7 +78,8 @@ public function beforeUnsubscribeCustomer(
}
}
}
- return [$customerId,$storeId];
+
+ return [$customerId, $storeId];
}
/**
@@ -106,7 +95,6 @@ public function beforeSubscribeCustomer(
$storeId
) {
if ($this->_helper->isMailChimpEnabled($storeId)) {
-
$subscriber = $this->_subscriberFactory->create()->loadByCustomer($customerId, $storeId);
if (!$subscriber->isSubscribed()) {
if (!$this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_MAGENTO_MAIL, $storeId)) {
@@ -143,6 +131,7 @@ public function beforeSubscribeCustomer(
}
}
}
+
return [$customerId, $storeId];
}
@@ -191,6 +180,7 @@ public function beforeSubscribe(
}
}
}
+
return [$email, $storeId];
}
@@ -219,6 +209,7 @@ public function beforeUnsubscribe(
$this->_helper->log($e->getFriendlyMessage());
}
}
- return [$email,$storeId,$confirmCode];
+
+ return [$email, $storeId, $confirmCode];
}
- }
+}
diff --git a/Model/ResourceModel/MailChimpErrors.php b/Model/ResourceModel/MailChimpErrors.php
index d3590c49..044cce12 100644
--- a/Model/ResourceModel/MailChimpErrors.php
+++ b/Model/ResourceModel/MailChimpErrors.php
@@ -1,18 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/17/16 1:57 PM
- * @file: MailChimpError.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpErrors extends AbstractDb
@@ -21,6 +10,7 @@ protected function _construct()
{
$this->_init('mailchimp_errors', 'id');
}
+
public function getByStoreIdType(\Ebizmarts\MailChimp\Model\MailChimpErrors $errors, $storeId, $id, $type)
{
$connection = $this->getConnection();
@@ -34,13 +24,18 @@ public function getByStoreIdType(\Ebizmarts\MailChimp\Model\MailChimpErrors $err
if ($data) {
$errors->setData($data);
}
+
return $errors;
}
+
public function deleteByStorePeriod(\Ebizmarts\MailChimp\Model\MailChimpErrors $errors, $storeId, $interval, $limit)
{
$connection = $this->getConnection();
$table = $this->getTable('mailchimp_errors');
- $ret = $connection->query("DELETE FROM $table WHERE date_add(added_at, interval $interval month) < now() AND store_id = $storeId LIMIT $limit");
+ $ret = $connection->query(
+ "DELETE FROM $table WHERE date_add(added_at, interval $interval month) < now() AND store_id = $storeId LIMIT $limit"
+ );
+
return $ret;
}
}
diff --git a/Model/ResourceModel/MailChimpInterestGroup.php b/Model/ResourceModel/MailChimpInterestGroup.php
index f0e2ffc7..1a557d64 100644
--- a/Model/ResourceModel/MailChimpInterestGroup.php
+++ b/Model/ResourceModel/MailChimpInterestGroup.php
@@ -1,19 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/20/17 3:51 PM
- * @file: MailChimpInterestGroup.php
- */
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpInterestGroup extends AbstractDb
@@ -22,13 +10,14 @@ protected function _construct()
{
$this->_init('mailchimp_interest_group', 'id');
}
+
public function getBySubscriberIdStoreId(
\Ebizmarts\MailChimp\Model\MailChimpInterestGroup $mailChimpInterestGroup,
$subscriberId,
$storeId
) {
$connection = $this->getConnection();
- $bind = ['subscriber_id'=>$subscriberId, 'store_id' => $storeId];
+ $bind = ['subscriber_id' => $subscriberId, 'store_id' => $storeId];
$select = $connection->select()->from(
$this->getTable('mailchimp_interest_group')
)->where(
@@ -38,6 +27,7 @@ public function getBySubscriberIdStoreId(
if ($data) {
$mailChimpInterestGroup->setData($data);
}
+
return $mailChimpInterestGroup;
}
}
diff --git a/Model/ResourceModel/MailChimpInterestGroup/Collection.php b/Model/ResourceModel/MailChimpInterestGroup/Collection.php
index cc79d6a3..0adf8788 100644
--- a/Model/ResourceModel/MailChimpInterestGroup/Collection.php
+++ b/Model/ResourceModel/MailChimpInterestGroup/Collection.php
@@ -1,10 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/3/17 11:42 AM
- * @file: MailChimpStores.php
- */
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpStores extends AbstractDb
diff --git a/Model/ResourceModel/MailChimpStores/Collection.php b/Model/ResourceModel/MailChimpStores/Collection.php
index 0bd1f432..191f6ed9 100644
--- a/Model/ResourceModel/MailChimpStores/Collection.php
+++ b/Model/ResourceModel/MailChimpStores/Collection.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/27/17 1:22 PM
- * @file: Collection.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores;
class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
diff --git a/Model/ResourceModel/MailChimpStores/Grid/Collection.php b/Model/ResourceModel/MailChimpStores/Grid/Collection.php
index 275ce696..0e8cd7cb 100644
--- a/Model/ResourceModel/MailChimpStores/Grid/Collection.php
+++ b/Model/ResourceModel/MailChimpStores/Grid/Collection.php
@@ -1,15 +1,11 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/17/16 2:27 PM
- * @file: MailChimpSyncBatches.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpSyncBatches extends AbstractDb
diff --git a/Model/ResourceModel/MailChimpSyncBatches/Collection.php b/Model/ResourceModel/MailChimpSyncBatches/Collection.php
index c91b1e75..d7331d3a 100644
--- a/Model/ResourceModel/MailChimpSyncBatches/Collection.php
+++ b/Model/ResourceModel/MailChimpSyncBatches/Collection.php
@@ -1,15 +1,4 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/21/16 4:16 PM
- * @file: Collection.php
- */
namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches;
diff --git a/Model/ResourceModel/MailChimpSyncEcommerce.php b/Model/ResourceModel/MailChimpSyncEcommerce.php
index 1ab2c641..0dcdca8b 100644
--- a/Model/ResourceModel/MailChimpSyncEcommerce.php
+++ b/Model/ResourceModel/MailChimpSyncEcommerce.php
@@ -1,19 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 12/1/16 2:33 PM
- * @file: MailChimpSyncEcommerce.php
- */
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpSyncEcommerce extends AbstractDb
@@ -22,6 +10,7 @@ protected function _construct()
{
$this->_init('mailchimp_sync_ecommerce', 'id');
}
+
public function getByStoreIdType(\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp, $storeId, $id, $type)
{
$connection = $this->getConnection();
@@ -35,8 +24,10 @@ public function getByStoreIdType(\Ebizmarts\MailChimp\Model\MailChimpSyncEcommer
if ($data) {
$chimp->setData($data);
}
+
return $chimp;
}
+
public function markAllAsDeleted(
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp,
$id,
@@ -46,21 +37,29 @@ public function markAllAsDeleted(
$connection = $this->getConnection();
$connection->update(
$this->getTable('mailchimp_sync_ecommerce'),
- ['mailchimp_sync_deleted'=>1, 'deleted_related_id'=> $relatedDeletedId],
- ['related_id = ?'=> $id,'type = ?'=>$type]
+ ['mailchimp_sync_deleted' => 1, 'deleted_related_id' => $relatedDeletedId],
+ ['related_id = ?' => $id, 'type = ?' => $type]
);
+
return $this;
}
+
public function markAllAsModified(\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp, $id, $type)
{
$connection = $this->getConnection();
$connection->update(
$this->getTable('mailchimp_sync_ecommerce'),
- ['mailchimp_sync_modified'=>1,'mailchimp_sent'=>\Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC,'batch_id'=>null],
- ['related_id = ?'=> $id, 'type = ?'=>$type]
+ [
+ 'mailchimp_sync_modified' => 1,
+ 'mailchimp_sent' => \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC,
+ 'batch_id' => null
+ ],
+ ['related_id = ?' => $id, 'type = ?' => $type]
);
+
return $this;
}
+
public function deleteAllByIdType(
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp,
$id,
@@ -70,24 +69,33 @@ public function deleteAllByIdType(
$connection = $this->getConnection();
$connection->delete(
$this->getTable('mailchimp_sync_ecommerce'),
- ['related_id = ?'=> $id, 'type = ?'=>$type, 'mailchimp_store_id = ?' => $mailchimpStoreId]
+ ['related_id = ?' => $id, 'type = ?' => $type, 'mailchimp_store_id = ?' => $mailchimpStoreId]
);
+
return $this;
}
+
public function deleteAllByBatchId(\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp, $batchId)
{
$connection = $this->getConnection();
$connection->delete($this->getTable('mailchimp_sync_ecommerce'), ['batch_id = ?' => $batchId]);
+
return $this;
}
- public function markAllAsModifiedByIds(\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp, $mailchimpStore, $ids, $type)
- {
+
+ public function markAllAsModifiedByIds(
+ \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimp,
+ $mailchimpStore,
+ $ids,
+ $type
+ ) {
$connection = $this->getConnection();
$connection->update(
$this->getTable('mailchimp_sync_ecommerce'),
- ['mailchimp_sync_modified'=>1],
- ['related_id in (?)'=> $ids, 'type = ?'=>$type, 'mailchimp_store_id = ?'=>$mailchimpStore]
+ ['mailchimp_sync_modified' => 1],
+ ['related_id in (?)' => $ids, 'type = ?' => $type, 'mailchimp_store_id = ?' => $mailchimpStore]
);
+
return $this;
}
}
diff --git a/Model/ResourceModel/MailChimpSyncEcommerce/Collection.php b/Model/ResourceModel/MailChimpSyncEcommerce/Collection.php
index 4917f008..59c5908b 100644
--- a/Model/ResourceModel/MailChimpSyncEcommerce/Collection.php
+++ b/Model/ResourceModel/MailChimpSyncEcommerce/Collection.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 12/1/16 2:36 PM
- * @file: Collection.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
diff --git a/Model/ResourceModel/MailChimpWebhookRequest.php b/Model/ResourceModel/MailChimpWebhookRequest.php
index d066ae89..0e541540 100644
--- a/Model/ResourceModel/MailChimpWebhookRequest.php
+++ b/Model/ResourceModel/MailChimpWebhookRequest.php
@@ -1,18 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/26/17 11:33 AM
- * @file: MailChimpWebhookRequest.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel;
-use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class MailChimpWebhookRequest extends AbstractDb
diff --git a/Model/ResourceModel/MailChimpWebhookRequest/Collection.php b/Model/ResourceModel/MailChimpWebhookRequest/Collection.php
index 3c4d3e5e..8d943d9b 100644
--- a/Model/ResourceModel/MailChimpWebhookRequest/Collection.php
+++ b/Model/ResourceModel/MailChimpWebhookRequest/Collection.php
@@ -1,15 +1,5 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/26/17 11:36 AM
- * @file: Collection.php
- */
+
namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
diff --git a/Model/ResourceModel/Schedule/Collection.php b/Model/ResourceModel/Schedule/Collection.php
index bb1b2a6f..8596e03f 100644
--- a/Model/ResourceModel/Schedule/Collection.php
+++ b/Model/ResourceModel/Schedule/Collection.php
@@ -2,29 +2,27 @@
namespace Ebizmarts\MailChimp\Model\ResourceModel\Schedule;
-use \Magento\Cron\Model\ResourceModel\Schedule as MagentoSchedule;
-use \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
+use Magento\Cron\Model\ResourceModel\Schedule as MagentoSchedule;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
+use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
use Psr\Log\LoggerInterface as Logger;
+
class Collection extends SearchResult
{
-
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
- $mainTable='cron_schedule',
- $resourceModel=MagentoSchedule::class
+ $mainTable = 'cron_schedule',
+ $resourceModel = MagentoSchedule::class
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
-
}//end __construct()
-
protected function _initSelect()
{
parent::_initSelect();
@@ -38,9 +36,8 @@ protected function _initSelect()
'ebizmarts_clean_errors'
)"
);
- return $this;
+ return $this;
}//end _initSelect()
-
}//end class
diff --git a/Observer/Adminhtml/Customer/SaveAfter.php b/Observer/Adminhtml/Customer/SaveAfter.php
index 6db0431e..3560bd90 100644
--- a/Observer/Adminhtml/Customer/SaveAfter.php
+++ b/Observer/Adminhtml/Customer/SaveAfter.php
@@ -1,17 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 12/1/17 2:21 PM
- * @file: SaveAfter.php
- */
namespace Ebizmarts\MailChimp\Observer\Adminhtml\Customer;
+
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class SaveAfter implements \Magento\Framework\Event\ObserverInterface
@@ -45,17 +35,16 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
SyncHelper $syncHelper
) {
-
- $this->helper = $helper;
- $this->subscriberFactory = $subscriberFactory;
+ $this->helper = $helper;
+ $this->subscriberFactory = $subscriberFactory;
$this->interestGroupFactory = $interestGroupFactory;
- $this->syncHelper = $syncHelper;
+ $this->syncHelper = $syncHelper;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$customer = $observer->getCustomer();
- $request = $observer->getEvent()->getRequest();
+ $request = $observer->getEvent()->getRequest();
$allParams = $request->getParams();
$subscriber = $this->subscriberFactory->create();
if (isset($allParams['customer']['interestgroup'])) {
diff --git a/Observer/Adminhtml/Product/DeleteAfter.php b/Observer/Adminhtml/Product/DeleteAfter.php
index 2c234dd6..5c1f3c08 100644
--- a/Observer/Adminhtml/Product/DeleteAfter.php
+++ b/Observer/Adminhtml/Product/DeleteAfter.php
@@ -2,13 +2,11 @@
namespace Ebizmarts\MailChimp\Observer\Adminhtml\Product;
+use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\ConfigurableFactory;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
-use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
-
-
class DeleteAfter implements ObserverInterface
{
@@ -36,10 +34,11 @@ public function __construct(
Configurable $configurable
) {
- $this->helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->configurable = $configurable;
+ $this->helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->configurable = $configurable;
}
+
function execute(Observer $observer)
{
$product = $observer->getProduct();
@@ -59,6 +58,7 @@ function execute(Observer $observer)
}
$this->_updateProduct($product->getId());
}
+
protected function _updateProduct($entityId)
{
$this->syncHelper->markEcommerceAsDeleted($entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT);
diff --git a/Observer/Adminhtml/Product/ImportAfter.php b/Observer/Adminhtml/Product/ImportAfter.php
index 77afc12a..cb6d56fd 100644
--- a/Observer/Adminhtml/Product/ImportAfter.php
+++ b/Observer/Adminhtml/Product/ImportAfter.php
@@ -2,9 +2,9 @@
namespace Ebizmarts\MailChimp\Observer\Adminhtml\Product;
-use Magento\Framework\Event\Observer;
-use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Framework\Event\Observer;
class ImportAfter implements \Magento\Framework\Event\ObserverInterface
{
@@ -22,12 +22,12 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
CollectionFactory $productCollectionFactory,
SyncHelper $syncHelper
- )
- {
+ ) {
$this->helper = $helper;
$this->productCollectionFactory = $productCollectionFactory;
$this->syncHelper = $syncHelper;
}
+
public function execute(Observer $observer)
{
try {
@@ -37,15 +37,15 @@ public function execute(Observer $observer)
foreach ($bunch as $product) {
if ($counter % 100 == 0 && count($skus)) {
$this->updateSkus($skus);
- $skus =[];
+ $skus = [];
}
$sku = $product['sku'];
- if (key_exists('_store', $product)&&!empty($product['_store'])) {
+ if (key_exists('_store', $product) && !empty($product['_store'])) {
$storeId = $product['_store'];
} else {
$storeId = 0;
}
- $skus[$storeId][]=$sku;
+ $skus[$storeId][] = $sku;
$counter++;
}
if (count($skus)) {
@@ -55,6 +55,7 @@ public function execute(Observer $observer)
$this->helper->log($e->getMessage());
}
}
+
protected function updateSkus($skus)
{
foreach ($skus as $storeId => $storeskus) {
@@ -63,7 +64,7 @@ protected function updateSkus($skus)
*/
$collection = $this->productCollectionFactory->create();
$collection->addStoreFilter($storeId);
- $collection->addFieldToFilter('sku', ['in'=>$storeskus]);
+ $collection->addFieldToFilter('sku', ['in' => $storeskus]);
$collection->addFieldToSelect('id');
$productIds = [];
foreach ($collection as $item) {
@@ -71,15 +72,18 @@ protected function updateSkus($skus)
}
$this->markAsModified($storeId, $productIds);
}
-
}
- protected function markAsModified($storeId,$productsIds)
+
+ protected function markAsModified($storeId, $productsIds)
{
$mailchimpStoreId = $this->helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$storeId
);
- $this->syncHelper->markAllAsModifiedByIds($mailchimpStoreId, $productsIds, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT);
-
+ $this->syncHelper->markAllAsModifiedByIds(
+ $mailchimpStoreId,
+ $productsIds,
+ \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT
+ );
}
}
diff --git a/Observer/Adminhtml/Product/SaveAfter.php b/Observer/Adminhtml/Product/SaveAfter.php
index 69c4c94e..41adc7a2 100644
--- a/Observer/Adminhtml/Product/SaveAfter.php
+++ b/Observer/Adminhtml/Product/SaveAfter.php
@@ -1,16 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 1/18/18 12:30 PM
- * @file: SaveAfter.php
- */
+
namespace Ebizmarts\MailChimp\Observer\Adminhtml\Product;
+
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class SaveAfter implements \Magento\Framework\Event\ObserverInterface
@@ -38,10 +29,9 @@ public function __construct(
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurable,
SyncHelper $syncHelper
) {
-
- $this->helper = $helper;
- $this->configurable = $configurable;
- $this->syncHelper = $syncHelper;
+ $this->helper = $helper;
+ $this->configurable = $configurable;
+ $this->syncHelper = $syncHelper;
}
public function execute(\Magento\Framework\Event\Observer $observer)
@@ -67,6 +57,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
}
$this->_updateProduct($product->getId(), $sync);
}
+
protected function _updateProduct($entityId, $sync)
{
if (!$sync) {
diff --git a/Observer/Adminhtml/Product/SaveBefore.php b/Observer/Adminhtml/Product/SaveBefore.php
index d879027c..5f12dcf3 100644
--- a/Observer/Adminhtml/Product/SaveBefore.php
+++ b/Observer/Adminhtml/Product/SaveBefore.php
@@ -2,19 +2,21 @@
namespace Ebizmarts\MailChimp\Observer\Adminhtml\Product;
+use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
-use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
+
class SaveBefore implements ObserverInterface
{
public function execute(Observer $observer)
{
$product = $observer->getProduct();
$sync = $product->getSync();
- if (!$sync&&$product->getMailchimpSent()!=MailchimpHelper::NEVERSYNC) {
+ if (!$sync && $product->getMailchimpSent() != MailchimpHelper::NEVERSYNC) {
$product->setMailchimpSent(MailchimpHelper::NEEDTORESYNC);
$product->setMailchimpSyncError(null);
}
+
return $this;
}
}
diff --git a/Observer/ConfigObserver.php b/Observer/ConfigObserver.php
index 3d49681d..be321020 100644
--- a/Observer/ConfigObserver.php
+++ b/Observer/ConfigObserver.php
@@ -1,20 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/23/17 12:22 PM
- * @file: ConfigObserver.php
- */
namespace Ebizmarts\MailChimp\Observer;
-use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer as EventObserver;
+use Magento\Framework\Event\ObserverInterface;
class ConfigObserver implements ObserverInterface
{
@@ -32,7 +21,6 @@ class ConfigObserver implements ObserverInterface
protected $_registry;
/**
- * ConfigObserver constructor.
* @param \Magento\Store\Model\StoreManager $storeManager
* @param \Magento\Framework\Registry $registry
* @param \Ebizmarts\MailChimp\Helper\Data $helper
@@ -42,16 +30,15 @@ public function __construct(
\Magento\Framework\Registry $registry,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
- $this->_helper = $helper;
- $this->_storeManager = $storeManager;
- $this->_registry = $registry;
+ $this->_helper = $helper;
+ $this->_storeManager = $storeManager;
+ $this->_registry = $registry;
}
public function execute(EventObserver $observer)
{
- $oldListId = $this->_registry->registry('oldListId');
- $apiKey = $this->_registry->registry('apiKey');
+ $oldListId = $this->_registry->registry('oldListId');
+ $apiKey = $this->_registry->registry('apiKey');
$mustDelete = true;
foreach ($this->_storeManager->getStores() as $storeId => $val) {
diff --git a/Observer/Customer/SaveBefore.php b/Observer/Customer/SaveBefore.php
index 772272ef..b7829bc8 100644
--- a/Observer/Customer/SaveBefore.php
+++ b/Observer/Customer/SaveBefore.php
@@ -1,21 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/8/17 5:07 PM
- * @file: SafeAfter.php
- */
+
namespace Ebizmarts\MailChimp\Observer\Customer;
-use Magento\Framework\Event\Observer;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
-
class SaveBefore implements \Magento\Framework\Event\ObserverInterface
{
/**
@@ -41,10 +29,9 @@ public function __construct(
SyncHelper $syncHelper,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
- $this->subscriberFactory = $subscriberFactory;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
+ $this->subscriberFactory = $subscriberFactory;
}
public function execute(\Magento\Framework\Event\Observer $observer)
@@ -53,7 +40,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
* @var $customer \Magento\Customer\Model\Customer
*/
$customer = $observer->getCustomer();
- $storeId = $customer->getStoreId();
+ $storeId = $customer->getStoreId();
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE)) {
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ECOMMERCE_ACTIVE)) {
$mailchimpStoreId = $this->_helper->getConfigValue(
diff --git a/Observer/Sales/Order/SaveAfter.php b/Observer/Sales/Order/SaveAfter.php
index 17480d0b..9891529f 100644
--- a/Observer/Sales/Order/SaveAfter.php
+++ b/Observer/Sales/Order/SaveAfter.php
@@ -1,22 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 2/15/17 3:38 PM
- * @file: SaveAfter.php
- */
namespace Ebizmarts\MailChimp\Observer\Sales\Order;
-use Magento\Framework\Event\Observer;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
-
class SaveAfter implements \Magento\Framework\Event\ObserverInterface
{
/**
@@ -36,9 +23,8 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
SyncHelper $syncHelper
) {
-
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
}
public function execute(\Magento\Framework\Event\Observer $observer)
diff --git a/Observer/Sales/Order/SubmitAfter.php b/Observer/Sales/Order/SubmitAfter.php
index 04f49ddc..1796a715 100644
--- a/Observer/Sales/Order/SubmitAfter.php
+++ b/Observer/Sales/Order/SubmitAfter.php
@@ -1,18 +1,6 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/26/17 12:36 PM
- * @file: SubmitAfter.php
- */
-namespace Ebizmarts\MailChimp\Observer\Sales\Order;
-use Magento\Framework\Event\Observer;
+namespace Ebizmarts\MailChimp\Observer\Sales\Order;
class SubmitAfter implements \Magento\Framework\Event\ObserverInterface
{
@@ -34,7 +22,6 @@ class SubmitAfter implements \Magento\Framework\Event\ObserverInterface
protected $_sessionManager;
/**
- * SubmitAfter constructor.
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $metadataFactory
* @param \Magento\Framework\Session\SessionManagerInterface $sessionManager
@@ -46,11 +33,10 @@ public function __construct(
\Magento\Framework\Session\SessionManagerInterface $sessionManager,
\Ebizmarts\MailChimp\Helper\Data $helper
) {
-
- $this->_cookieManager = $cookieManager;
- $this->_helper = $helper;
- $this->_cookieMetadataFactory = $metadataFactory;
- $this->_sessionManager = $sessionManager;
+ $this->_cookieManager = $cookieManager;
+ $this->_helper = $helper;
+ $this->_cookieMetadataFactory = $metadataFactory;
+ $this->_sessionManager = $sessionManager;
}
public function execute(\Magento\Framework\Event\Observer $observer)
diff --git a/Observer/Sales/Order/SubmitBefore.php b/Observer/Sales/Order/SubmitBefore.php
index 51474098..f0d11234 100644
--- a/Observer/Sales/Order/SubmitBefore.php
+++ b/Observer/Sales/Order/SubmitBefore.php
@@ -1,18 +1,6 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/14/17 11:26 PM
- * @file: SaveBefore.php
- */
-namespace Ebizmarts\MailChimp\Observer\Sales\Order;
-use Magento\Framework\Event\Observer;
+namespace Ebizmarts\MailChimp\Observer\Sales\Order;
class SubmitBefore implements \Magento\Framework\Event\ObserverInterface
{
@@ -21,6 +9,7 @@ class SubmitBefore implements \Magento\Framework\Event\ObserverInterface
'mailchimp_campaign_id',
'mailchimp_landing_page'
];
+
public function execute(\Magento\Framework\Event\Observer $observer)
{
/* @var \Magento\Sales\Model\Order $order */
@@ -38,6 +27,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
}
}
$order->setData('mailchimp_flag', $flag);
+
return $this;
}
}
diff --git a/Observer/SalesRule/Rule/DeleteAfter.php b/Observer/SalesRule/Rule/DeleteAfter.php
index 79135684..afed0e96 100644
--- a/Observer/SalesRule/Rule/DeleteAfter.php
+++ b/Observer/SalesRule/Rule/DeleteAfter.php
@@ -1,21 +1,9 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/19/17 5:26 PM
- * @file: DeleteAfter.php
- */
+
namespace Ebizmarts\MailChimp\Observer\SalesRule\Rule;
-use Magento\Framework\Event\Observer;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
-
class DeleteAfter implements \Magento\Framework\Event\ObserverInterface
{
/**
@@ -35,9 +23,8 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce,
SyncHelper $syncHelper
) {
-
- $this->_ecommerce = $ecommerce;
- $this->syncHelper = $syncHelper;
+ $this->_ecommerce = $ecommerce;
+ $this->syncHelper = $syncHelper;
}
public function execute(\Magento\Framework\Event\Observer $observer)
diff --git a/Observer/SalesRule/Rule/SaveAfter.php b/Observer/SalesRule/Rule/SaveAfter.php
index c8799424..36a2fee3 100644
--- a/Observer/SalesRule/Rule/SaveAfter.php
+++ b/Observer/SalesRule/Rule/SaveAfter.php
@@ -1,19 +1,7 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 10/19/17 4:14 PM
- * @file: Rule.php
- */
namespace Ebizmarts\MailChimp\Observer\SalesRule\Rule;
-use Magento\Framework\Event\Observer;
use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class SaveAfter implements \Magento\Framework\Event\ObserverInterface
@@ -30,7 +18,6 @@ class SaveAfter implements \Magento\Framework\Event\ObserverInterface
private $syncHelper;
/**
- * SaveAfter constructor.
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
@@ -41,10 +28,10 @@ public function __construct(
\Magento\Framework\Stdlib\DateTime\DateTime $date,
SyncHelper $syncHelper
) {
- $this->_ecommerce = $ecommerce;
- $this->_helper = $helper;
- $this->_date = $date;
- $this->syncHelper = $syncHelper;
+ $this->_ecommerce = $ecommerce;
+ $this->_helper = $helper;
+ $this->_date = $date;
+ $this->syncHelper = $syncHelper;
}
public function execute(\Magento\Framework\Event\Observer $observer)
diff --git a/Observer/Subscriber/SaveAfter.php b/Observer/Subscriber/SaveAfter.php
index 3c055a17..66a356aa 100644
--- a/Observer/Subscriber/SaveAfter.php
+++ b/Observer/Subscriber/SaveAfter.php
@@ -1,18 +1,6 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 11/9/17 5:20 PM
- * @file: SaveBefore.php
- */
-namespace Ebizmarts\MailChimp\Observer\Subscriber;
-use Magento\Framework\Event\Observer;
+namespace Ebizmarts\MailChimp\Observer\Subscriber;
class SaveAfter implements \Magento\Framework\Event\ObserverInterface
{
@@ -34,7 +22,6 @@ class SaveAfter implements \Magento\Framework\Event\ObserverInterface
protected $_subscriberFactory;
/**
- * SaveBefore constructor.
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\Api\Subscriber $subscriberApi
@@ -46,11 +33,10 @@ public function __construct(
\Ebizmarts\MailChimp\Model\Api\Subscriber $subscriberApi,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
) {
-
- $this->_ecommerce = $ecommerce;
- $this->_helper = $helper;
- $this->_subscriberApi = $subscriberApi;
- $this->_subscriberFactory = $subscriberFactory;
+ $this->_ecommerce = $ecommerce;
+ $this->_helper = $helper;
+ $this->_subscriberApi = $subscriberApi;
+ $this->_subscriberFactory = $subscriberFactory;
}
public function execute(\Magento\Framework\Event\Observer $observer)
@@ -65,8 +51,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if ($isCustomer) {
$subscriberOld = $factory->loadBySubscriberEmail($subscriber->getCustomerId(), $subscriber->getStoreId());
}
- if ($this->_helper->isMailChimpEnabled($subscriber->getStoreId())&&$isCustomer&&
- $subscriberOld->getEmail()&&$subscriber->getEmail()!=$subscriberOld->getEmail()) {
+ if ($this->_helper->isMailChimpEnabled($subscriber->getStoreId()) && $isCustomer &&
+ $subscriberOld->getEmail() && $subscriber->getEmail() != $subscriberOld->getEmail()) {
$api = $this->_helper->getApi($subscriberOld->getStoreId());
$mergeVars = $this->_helper->getMergeVarsBySubscriber($subscriberOld, $subscriberOld->getEmail());
$status = 'unsubscribed';
@@ -88,7 +74,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
-
}
$this->_subscriberApi->update($subscriber);
}
diff --git a/Setup/Patch/Data/Migrate24.php b/Setup/Patch/Data/Migrate24.php
index baa4ef18..47760c7f 100644
--- a/Setup/Patch/Data/Migrate24.php
+++ b/Setup/Patch/Data/Migrate24.php
@@ -17,8 +17,7 @@ class Migrate24 implements DataPatchInterface, PatchVersionInterface
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup
- )
- {
+ ) {
$this->moduleDataSetup = $moduleDataSetup;
}
@@ -28,10 +27,17 @@ public function apply()
$table = $this->moduleDataSetup->getTable('sales_order');
$select = $this->moduleDataSetup->getConnection()->select()
->from(
- false,
- ['mailchimp_flag' => new \Zend_Db_Expr('IF(mailchimp_abandonedcart_flag OR mailchimp_campaign_id OR mailchimp_landing_page, 1, 0)')]
- )->join(['O'=>$table], 'O.entity_id = G.entity_id', []);
- $query = $this->moduleDataSetup->getConnection()->updateFromSelect($select, ['G' => $this->moduleDataSetup->getTable('sales_order_grid')]);
+ false,
+ [
+ 'mailchimp_flag' => new \Zend_Db_Expr(
+ 'IF(mailchimp_abandonedcart_flag OR mailchimp_campaign_id OR mailchimp_landing_page, 1, 0)'
+ )
+ ]
+ )->join(['O' => $table], 'O.entity_id = G.entity_id', []);
+ $query = $this->moduleDataSetup->getConnection()->updateFromSelect(
+ $select,
+ ['G' => $this->moduleDataSetup->getTable('sales_order_grid')]
+ );
$this->moduleDataSetup->getConnection()->query($query);
@@ -39,14 +45,17 @@ public function apply()
return $this;
}
+
public static function getDependencies()
{
return [];
}
+
public function getAliases()
{
return [];
}
+
public static function getVersion()
{
return '1.0.24';
diff --git a/Setup/Patch/Data/Migrate32.php b/Setup/Patch/Data/Migrate32.php
index 4453d814..7ff66495 100644
--- a/Setup/Patch/Data/Migrate32.php
+++ b/Setup/Patch/Data/Migrate32.php
@@ -2,10 +2,10 @@
namespace Ebizmarts\MailChimp\Setup\Patch\Data;
use Ebizmarts\MailChimp\Helper\Data;
+use Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest\CollectionFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
-use Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest\CollectionFactory;
class Migrate32 implements DataPatchInterface, PatchVersionInterface
{
@@ -26,8 +26,7 @@ public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
Data $helper,
CollectionFactory $webhookCollectionFactory
- )
- {
+ ) {
$this->moduleDataSetup = $moduleDataSetup;
$this->helper = $helper;
$this->webhookCollectionFactory = $webhookCollectionFactory;
@@ -39,7 +38,10 @@ public function apply()
// delete the old serialized data from core_config_data
$table = $this->moduleDataSetup->getTable('core_config_data');
try {
- $this->moduleDataSetup->getConnection()->delete($table, ['path = ?'=> \Ebizmarts\MailChimp\Helper\Data::XML_MERGEVARS]);
+ $this->moduleDataSetup->getConnection()->delete(
+ $table,
+ ['path = ?' => \Ebizmarts\MailChimp\Helper\Data::XML_MERGEVARS]
+ );
} catch (\Exception $e) {
$this->helper->log($e->getMessage());
}
@@ -78,14 +80,17 @@ public function apply()
return $this;
}
+
public static function getDependencies()
{
return [];
}
+
public function getAliases()
{
return [];
}
+
public static function getVersion()
{
return '1.2.32';
diff --git a/Setup/Patch/Data/Migrate35.php b/Setup/Patch/Data/Migrate35.php
index 34c71fbc..4c0d4034 100644
--- a/Setup/Patch/Data/Migrate35.php
+++ b/Setup/Patch/Data/Migrate35.php
@@ -2,10 +2,10 @@
namespace Ebizmarts\MailChimp\Setup\Patch\Data;
use Ebizmarts\MailChimp\Helper\Data;
+use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory as ConfigFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
-use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory as ConfigFactory;
class Migrate35 implements DataPatchInterface, PatchVersionInterface
{
@@ -31,8 +31,7 @@ public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
Data $helper,
ConfigFactory $configFactory
- )
- {
+ ) {
$this->moduleDataSetup = $moduleDataSetup;
$this->helper = $helper;
$this->configFactory = $configFactory;
@@ -67,14 +66,17 @@ public function apply()
return $this;
}
+
public static function getDependencies()
{
return [];
}
+
public function getAliases()
{
return [];
}
+
public static function getVersion()
{
return '102.3.35';
diff --git a/Setup/Patch/Data/Migrate452.php b/Setup/Patch/Data/Migrate452.php
index d76b5086..54dcff8e 100644
--- a/Setup/Patch/Data/Migrate452.php
+++ b/Setup/Patch/Data/Migrate452.php
@@ -2,11 +2,11 @@
namespace Ebizmarts\MailChimp\Setup\Patch\Data;
+use Ebizmarts\MailChimp\Helper\Data;
+use Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory as SyncFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
-use Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory as SyncFactory;
-use Ebizmarts\MailChimp\Helper\Data;
class Migrate452 implements DataPatchInterface
{
@@ -38,13 +38,13 @@ public function __construct(
SyncFactory $syncFactory,
OrderRepositoryInterface $orderRepository,
Data $helper
- )
- {
+ ) {
$this->moduleDataSetup = $moduleDataSetup;
$this->syncFactory = $syncFactory;
$this->orderRepository = $orderRepository;
$this->helper = $helper;
}
+
public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();
@@ -56,8 +56,7 @@ public function apply()
$query .= "SET A.`mailchimp_sync_error` = B.`mailchimp_sync_error`, A.`mailchimp_sent` = B.`mailchimp_sent` ";
$query .= "WHERE B.`type` = 'ORD'";
$this->moduleDataSetup->getConnection()->query($query);
-
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->helper->log($e->getMessage());
throw new \Exception($e->getMessage());
}
@@ -69,8 +68,7 @@ public function apply()
$query .= "SET A.`mailchimp_sync_error` = B.`mailchimp_sync_error`, A.`mailchimp_sent` = B.`mailchimp_sent` ";
$query .= "WHERE B.`type` = 'ORD'";
$this->moduleDataSetup->getConnection()->query($query);
-
- } catch(\Exception $e) {
+ } catch (\Exception $e) {
$this->helper->log($e->getMessage());
throw new \Exception($e->getMessage());
}
@@ -97,6 +95,7 @@ public static function getDependencies()
{
return [];
}
+
public function getAliases()
{
return [];
diff --git a/Setup/Uninstall.php b/Setup/Uninstall.php
index 7b238c98..075705ab 100644
--- a/Setup/Uninstall.php
+++ b/Setup/Uninstall.php
@@ -40,11 +40,11 @@ public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $c
foreach ($tables as $table) {
$connection->dropTable($setup->getTable($table));
}
- foreach($tablesFields as $table => $columnArray) {
- foreach($columnArray as $column) {
- $connection->dropColumn( $setup->getTable($table), $column);
+ foreach ($tablesFields as $table => $columnArray) {
+ foreach ($columnArray as $column) {
+ $connection->dropColumn($setup->getTable($table), $column);
}
}
$installer->endSetup();
}
-}
\ No newline at end of file
+}
diff --git a/Ui/Component/Batch/Grid/Column/Batches.php b/Ui/Component/Batch/Grid/Column/Batches.php
index bf1f60ab..93b55543 100644
--- a/Ui/Component/Batch/Grid/Column/Batches.php
+++ b/Ui/Component/Batch/Grid/Column/Batches.php
@@ -1,23 +1,11 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/3/17 3:10 PM
- * @file: Batch.php
- */
-
namespace Ebizmarts\MailChimp\Ui\Component\Batch\Grid\Column;
+use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
-use Magento\Framework\UrlInterface;
class Batches extends Column
{
@@ -33,11 +21,10 @@ class Batches extends Column
* @var Helper
*/
protected $helper;
-
- private $stores=[];
+
+ private $stores = [];
/**
- * Batch constructor.
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
@@ -90,6 +77,7 @@ public function prepareDataSource(array $dataSource)
];
}
}
+
return $dataSource;
}
@@ -100,6 +88,7 @@ private function getMCStoreNameById($mailchimp_store_id, $magentoStoreId)
$store = $api->ecommerce->stores->get($mailchimp_store_id);
$this->stores[$mailchimp_store_id] = $store['name'];
}
+
return $this->stores[$mailchimp_store_id];
}
}
diff --git a/Ui/Component/Errors/Grid/Column/Batch.php b/Ui/Component/Errors/Grid/Column/Batch.php
index e5c51ea3..5733eaad 100644
--- a/Ui/Component/Errors/Grid/Column/Batch.php
+++ b/Ui/Component/Errors/Grid/Column/Batch.php
@@ -1,22 +1,11 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 5/3/17 3:10 PM
- * @file: Batch.php
- */
namespace Ebizmarts\MailChimp\Ui\Component\Errors\Grid\Column;
+use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
-use Magento\Framework\UrlInterface;
class Batch extends Column
{
@@ -26,7 +15,6 @@ class Batch extends Column
protected $urlBuilder;
/**
- * Batch constructor.
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
@@ -43,12 +31,13 @@ public function __construct(
$this->urlBuilder = $urlBuilder;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
+
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
$edit = false;
- switch($item['regtype']) {
+ switch ($item['regtype']) {
case \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER:
$label = 'Edit customer';
$url = 'customer/index/edit';
@@ -76,16 +65,16 @@ public function prepareDataSource(array $dataSource)
),
'label' => 'Download Response'
]
- ];
+ ];
if ($edit) {
$item[$this->getData('name')]['edit'] =
- [
- 'href' => $this->urlBuilder->getUrl(
- $url,
- [$id => $item['original_id']]
- ),
- 'label' => $label
- ];
+ [
+ 'href' => $this->urlBuilder->getUrl(
+ $url,
+ [$id => $item['original_id']]
+ ),
+ 'label' => $label
+ ];
}
}
}
diff --git a/Ui/Component/Listing/Column/Customers.php b/Ui/Component/Listing/Column/Customers.php
index 33cde55d..d6768585 100644
--- a/Ui/Component/Listing/Column/Customers.php
+++ b/Ui/Component/Listing/Column/Customers.php
@@ -2,12 +2,12 @@
namespace Ebizmarts\MailChimp\Ui\Component\Listing\Column;
+use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
+use Magento\Customer\Model\CustomerFactory;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
-use Magento\Customer\Model\CustomerFactory;
-use Ebizmarts\MailChimp\Helper\Sync as SyncHelper;
class Customers extends Column
{
@@ -58,13 +58,13 @@ public function __construct(
SyncHelper $syncHelper,
\Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory,
array $components = [],
- array $data = [])
- {
+ array $data = []
+ ) {
$this->_requestInterface = $requestInterface;
$this->_assetRepository = $assetRepository;
$this->_customerFactory = $customerFactory;
- $this->_helper = $helper;
- $this->syncHelper = $syncHelper;
+ $this->_helper = $helper;
+ $this->syncHelper = $syncHelper;
$this->_mailChimpErrorsFactory = $mailChimpErrorsFactory;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
@@ -82,7 +82,10 @@ public function prepareDataSource(array $dataSource)
$alt = '';
$url = '';
$text = '';
- if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $customer->getStoreId())) {
+ if ($this->_helper->getConfigValue(
+ \Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE,
+ $customer->getStoreId()
+ )) {
$mailchimpStoreId = $this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$customer->getStoreId()
@@ -153,22 +156,23 @@ public function prepareDataSource(array $dataSource)
);
$text = __('Error');
}
-
}
-
}
$item['mailchimp_sync'] =
- "";
+ "";
}
}
+
return $dataSource;
}
+
private function _getError($customerId, $storeId)
{
/**
* @var $error \Ebizmarts\MailChimp\Model\MailChimpErrors
*/
$error = $this->_mailChimpErrorsFactory->create();
+
return $error->getByStoreIdType($storeId, $customerId, \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER);
}
diff --git a/Ui/Component/Listing/Column/Monkey.php b/Ui/Component/Listing/Column/Monkey.php
index 218b1099..1e52a79f 100644
--- a/Ui/Component/Listing/Column/Monkey.php
+++ b/Ui/Component/Listing/Column/Monkey.php
@@ -1,23 +1,13 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 3/15/17 1:23 AM
- * @file: Monkey.php
- */
+
namespace Ebizmarts\MailChimp\Ui\Component\Listing\Column;
-use \Magento\Sales\Api\OrderRepositoryInterface;
-use \Magento\Framework\View\Element\UiComponent\ContextInterface;
-use \Magento\Framework\View\Element\UiComponentFactory;
-use \Magento\Ui\Component\Listing\Columns\Column;
-use \Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\UrlInterface;
+use Magento\Framework\View\Element\UiComponent\ContextInterface;
+use Magento\Framework\View\Element\UiComponentFactory;
+use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Ui\Component\Listing\Columns\Column;
class Monkey extends Column
{
@@ -73,7 +63,7 @@ class Monkey extends Column
* @param \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $syncCommerceCF
* @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory
* @param \Magento\Sales\Model\OrderFactory $orderFactory
- *
+ * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
@@ -94,17 +84,16 @@ public function __construct(
array $components = [],
array $data = []
) {
-
$this->_orderRepository = $orderRepository;
- $this->_searchCriteria = $criteria;
+ $this->_searchCriteria = $criteria;
$this->_assetRepository = $assetRepository;
- $this->_requestInterfase= $requestInterface;
- $this->_helper = $helper;
- $this->_syncCommerceCF = $syncCommerceCF;
- $this->_orderFactory = $orderFactory;
+ $this->_requestInterfase = $requestInterface;
+ $this->_helper = $helper;
+ $this->_syncCommerceCF = $syncCommerceCF;
+ $this->_orderFactory = $orderFactory;
$this->orderCollectionFactory = $orderCollectionFactory;
- $this->_mailChimpErrorsFactory = $mailChimpErrorsFactory;
- $this->urlBuilder = $urlBuilder;
+ $this->_mailChimpErrorsFactory = $mailChimpErrorsFactory;
+ $this->urlBuilder = $urlBuilder;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
@@ -180,14 +169,14 @@ public function prepareDataSource(array $dataSource)
$alt = $item['mailchimp_sync_error'];
break;
default:
- $url ='';
+ $url = '';
$text = '';
}
$item['mailchimp_sync'] =
- "$text
";
+ "$text
";
if ($status) {
$item['mailchimp_sync'] =
- "$text
";
+ "$text
";
if ($menu) {
$item[$this->getData('name')] = [
'campaign' => [
@@ -210,21 +199,22 @@ public function prepareDataSource(array $dataSource)
}
} else {
$item['mailchimp_sync'] =
- "$text
";
+ "$text
";
}
-
}
}
}
return $dataSource;
}
+
private function _getError($orderId, $storeId)
{
/**
* @var $error \Ebizmarts\MailChimp\Model\MailChimpErrors
*/
$error = $this->_mailChimpErrorsFactory->create();
+
return $error->getByStoreIdType($storeId, $orderId, \Ebizmarts\MailChimp\Helper\Data::IS_ORDER);
}
diff --git a/Ui/Component/Listing/Column/Products.php b/Ui/Component/Listing/Column/Products.php
index 6f0aa661..b8197f5f 100644
--- a/Ui/Component/Listing/Column/Products.php
+++ b/Ui/Component/Listing/Column/Products.php
@@ -67,8 +67,8 @@ public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepository,
\Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory,
array $components = [],
- array $data = [])
- {
+ array $data = []
+ ) {
$this->_productFactory = $productFactory;
$this->productCollectionFactory = $productCollectionFactory;
$this->_requestInterface = $requestInterface;
@@ -164,17 +164,20 @@ public function prepareDataSource(array $dataSource)
$alt = "Mailchimp does not support bundled or grouped products.";
}
$item['mailchimp_sync'] =
- "";
+ "";
}
}
+
return $dataSource;
}
+
private function _getError($productId, $storeId)
{
/**
* @var $error \Ebizmarts\MailChimp\Model\MailChimpErrors
*/
$error = $this->_mailChimpErrorsFactory->create();
+
return $error->getByStoreIdType($storeId, $productId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT);
}
diff --git a/Ui/Component/Stores/Grid/Column/Actions.php b/Ui/Component/Stores/Grid/Column/Actions.php
index 5b4da997..18c98124 100644
--- a/Ui/Component/Stores/Grid/Column/Actions.php
+++ b/Ui/Component/Stores/Grid/Column/Actions.php
@@ -1,25 +1,12 @@
- * @copyright Ebizmarts (http://ebizmarts.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @date: 4/5/17 11:19 AM
- * @file: Actions.php
- */
+
namespace Ebizmarts\MailChimp\Ui\Component\Stores\Grid\Column;
+use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
-use Magento\Framework\UrlInterface;
-/**
- * Class ProductActions
- */
class Actions extends Column
{
/**
@@ -47,15 +34,12 @@ public function __construct(
/**
* Prepare Data Source
- *
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
- $storeId = $this->context->getFilterParam('store_id');
-
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['edit'] = [
'href' => $this->urlBuilder->getUrl(
diff --git a/etc/acl.xml b/etc/acl.xml
index eddc1447..88853622 100644
--- a/etc/acl.xml
+++ b/etc/acl.xml
@@ -1,16 +1,6 @@
diff --git a/etc/crontab.xml b/etc/crontab.xml
index 4647e4a2..03da20bb 100644
--- a/etc/crontab.xml
+++ b/etc/crontab.xml
@@ -1,16 +1,6 @@